Topic
2 replies Latest Post - ‏2012-09-03T15:35:54Z by gotqn
gotqn
gotqn
6 Posts
ACCEPTED ANSWER

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:

https://github.com/jruby/activerecord-jdbc-adapter

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'
else
gem 'sqlite3-ruby', :require => 'sqlite3'
end

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

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

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

    The search feature of developerWorks is your best friend :-)
    http://www.ibm.com/developerworks/data/library/techarticle/dm-0606dumbill/

    It gives you a sample yml file.

    Regards.

    Yves-Antoine Emmanuelli
    • gotqn
      gotqn
      6 Posts
      ACCEPTED ANSWER

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

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

      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:

      https://rubygems.org/gems/activerecord-jdbc-adapter/versions/1.0.3-java

      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:

      development:
      adapter: jdbc
      driver: com.ibm.db2.jcc.DB2Driver
      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.