16 November 2011
From the searching I have done, getting a working gem for Sybase is close to impossible for MRI Ruby, but it is pretty simple for JRuby.
With that all installed and working, the following sample code should connect to a Sybase instance (changing the hostname, port, user, and password):
require 'java'
java_import 'net.sourceforge.jtds.jdbc.Driver'
require 'rubygems'
require 'dbi'
dbh = DBI.connect('dbi:Jdbc:jtds:sybase://hostname:port/cfg', 'user', 'password', {'driver' => 'net.sourceforge.jtds.jdbc.Driver'} )
stmt = dbh.prepare("select account_number from account")
stmt.execute
while (r = stmt.fetch) do
puts r
end
stmt.finish