PraveenJ
PraveenJ

Reputation: 31

JDBC connectivity using ruby not jruby

Is there any gem available to Connect to JDBC DB2 for the Ruby project. I have come across activerecord-jdbc-adapter but it works only for Jruby.

Also can i use Jruby specific gem in Ruby? I have Ruby 2.2 and Jruby 9.0.0 in my machine

Upvotes: 2

Views: 1857

Answers (1)

PraveenJ
PraveenJ

Reputation: 31

Did it using two other gems which was mentioned in one site.

We need Sequel and ibm_db gems and ran the below code, it worked

require 'rubygems'
require 'sequel'
require 'ibm_db'

Sequel.connect("ibmdb://#{username}:#{password}@#{db_url}") do |db|
  db.fetch(selectquery) do |row|
    puts row
  end
end

Upvotes: 1

Related Questions