IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2012-09-03T15:35:54Z by gotqn
6 Posts

Pinned topic JRuby database.yml file configuration to use IBM DB2

‏2012-08-26T09:00:07Z |
I have installed:

JRuby (1.7.0.preview2)
Rails (3.2.8)
IBM DB2 Express C (1.01)
active-record-jdbc-adapter (1.2.2)
How should I change the database.yml file in order to my rails application to connect to DB2 database?

I have followed this article:

but there is no example with DB2 database. Also, why it is said that I should change Jruby to use always JDBC adapter.

If you’re using Rails 3, you’ll need to modify your Gemfile to use the activerecord-jdbc-adapter gem under JRuby. Change your Gemfile to look like the following (using sqlite3 as an example):

if defined?(JRUBY_VERSION)
gem 'activerecord-jdbc-adapter'
gem 'jdbc-sqlite3'
gem 'sqlite3-ruby', :require => 'sqlite3'

and where should I put the statement above?
Updated on 2012-09-03T15:35:54Z at 2012-09-03T15:35:54Z by gotqn
  • SystemAdmin
    5837 Posts

    Re: JRuby database.yml file configuration to use IBM DB2

    ‏2012-09-03T13:20:03Z  in response to gotqn

    The search feature of developerWorks is your best friend :-)

    It gives you a sample yml file.


    Yves-Antoine Emmanuelli
    • gotqn
      6 Posts

      Re: JRuby database.yml file configuration to use IBM DB2

      ‏2012-09-03T15:35:54Z  in response to SystemAdmin

      I have already checked this article. The example there refers to ruby an rails on ruby, not Jruby.

      The IBM has special driver for ruby, but if you need to use Jruby you should use the following driver:

      Unfortunately, in this gem documentation there is no example of the settings that you should apply when you are using IBM DB2.

      Anyway, I have been able to find finally some information in the context of other examples that let me to this:

      adapter: jdbc
      url: jdbc:db2://localhost:50000/TEST
      username: Joro
      password: mypass

      where "driver" field remains the same, and the url is your database url.

      I am "extremely" new in DB2, but find that the easy way to get this url is from "Data Studio 3.1.1 Administration Client" database properties.

      Unfortunately, I am in process of learning both db2 and jruby, so I was not able to test this successfully and am still not able to prove this is the solution of the issue.

      Anyway, I will update this settings if I find something wrong in the future.