Using Sybase ASE 12.5.4 with jTDS drivers with JRuby

£可爱£侵袭症+ 提交于 2019-12-03 20:19:58

I had been using the Sybase drivers for sometime as suggested by @lollipopman which was helpful in getting going but as I built more complex queries I kept running into issues so I tried to revisit the original problem and with an hour or so I go it working.

Find the open source jTDS drivers here

require java
require jtds-1.2.5.jar
require rubygems
require dbi

dbh = DBI.connect('dbi:Jdbc:jtds:sybase://<host>:<port>/<db>', <username>, <password>, {'driver' => 'net.sourceforge.jtds.jdbc.Driver'} )

And that is all that is needed to connect to your Sybase Database with JRuby and DBI

Hope this helps someone!

user183092

not entirely relevant, but this is what is required when using jruby, sybase jdbc and dbi:

require 'java'
require './jars/jTDS3.jar'
require './jars/jconn3.jar'
require "rubygems"
require "dbi"

dbh = DBI.connect('dbi:Jdbc:sybase:Tds:foobar:2460/testdb', 'sa', 'password',
  {'driver' => 'com.sybase.jdbc3.jdbc.SybDriver'} )

Note : you are saying "set rowcount" and "select". These are two different statements - they both get results, even if it's "0 rows" ... So you ARE getting a resultset. Try to execute those separately.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!