使用续集gem与db2

时间:2016-01-19 19:54:04

标签: java ruby-on-rails ruby jdbc

如何使用Sequel gem连接到db2数据库,  我正在尝试下面的命令,

 connection = Sequel.connect(:adapter => 'jdbc', 
   :driver => 'com.ibm.db2.jcc.DB2Driver',
   :host => 'jdbc:db2://myhostname/50000/dbname', 
   :user=> 'userid',
   :password=>'password')

但仍然无法连接,请提示我是否遗漏了任何内容。谢谢!

1 个答案:

答案 0 :(得分:0)

仅供记录:问题已解决:

require 'sequel' 
require 'logger' 
require 'activerecord-jdbc-adapter' 
require 'file path of sqljdbc4.jar' 
require 'file path of \db2jcc_license_cisuz.jar' 
require 'file path of \db2jcc_license_cu.jar' 
require 'file path of \db2jcc.jar' 

connection = Sequel.connect(
  adapter: "jdbc", 
  url: "jdbc:db2://xyx.pqr.net:PORT/Databasename:user=username;password=password;", 
  host: "xyz.net", 
  port: "11111", 
  database: "Databasename
)