Library for connecting to Oracle databases.
Net::TNS for Ruby is a partial implementation of the TNS (Transparent Network Substrate) and TTI (Two-Task Interface, a.k.a. TTC) protocols used by Oracle Database. It allows users to connect and authenticate to databases; functionality beyond that point is limited. The library implements two protocols, and although TTI is the higher-level one, the library is named for TNS, which is more well-known.
Net::TNS was written for and has been most tested with Ruby 2. The specs pass on 1.9.3, although their coverage is incomplete. It may be able to work with previous versions.
gem install net-tns
Because TNS and TTI are highly related (and not very useful without the other), they are both implemented in this library, although in separate namespaces, Net::TNS and Net::TTI (
require "net/tti" is sufficient to load both protocols, while
require "net/tns" will only load the TNS implementation).
Each namespace includes a Client class, which provides access to the essential functionality for that protocol.
Get the version of an Oracle DB server
require "net/tns" # require "net/tti" would work as well Net::TNS::Client.get_version(:host => "10.0.0.10") # => "188.8.131.52.0"
Try authenticating to a server
require "net/tti" # requiring TTI is necessary to get the higher-level functionality tti_client = Net::TTI::Client.new tti_client.connect( :host => "10.0.0.10", :sid => "ORCL" ) begin tti_client.authenticate( "jsmith", "bananas" ) # Authentication succeeded rescue Net::TTI::Exceptions::InvalidCredentialsError # Handle invalid credentials end tti_client.disconnect
Pull requests welcome! Once you've forked and cloned the project, you can
bundle install to take care of the dependencies; after that, you're ready to code.
You can also create issues for any bugs or feature requests, but they may take longer to get done, of course.
Resources on TNS and TTI
- https://community.oracle.com/thread/555302?start=0&tstart=0 (for naming of high-level components)
- The Oracle Hacker's Handbook by David Litchfield