Saturday, January 31, 2009

DB2 on Rails

It's time to test running Rails with DB2 as the backend.

I downloaded the information from http://www.alphaworks.ibm.com/tech/db2onrails.

I am running on Linux, so I did:

  • export DB2DIR=/opt/IBM/db2/V9.1_01
  • export DB2LIB=/opt/IBM/db2/V9.1_01/lib32
then:

  • cd Source
  • rake
It failed with the following message:

checking for SQLConnect() in -ldb2... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Looking at the mkmf.log, I see:

conftest.c:3: error: ‘SQLConnect’ undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)

  • It seems the environment variables were not set properly.
  • I ran it again and got the following message:
Database environment is not set up
Run ". /home/db2inst1/sqllib/db2profile" and retry


After sourcing the db2profile, I ran with the following messages:

Loaded suite tests
Started
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Finished in 0.593455 seconds.

But I seems the shared library has been generated successfully.

  • cp ibm_db2.so /usr/local/lib/ruby/site_ruby/1.8/i686-linux/
Installing the Adapter

  • cp ibm_db2_adapter.rb /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/
  • vi /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record.rb

Well, after trying that without success, I found the following response in the forum:

Given that RAILS_CONNECTION_ADAPTERS went away, the IBM gem is no longer called "ibm_db2", and that the minimum software requirements have changed, I recommend skipping the "Toolkit for DB2 on Rails" and to start learning about the "ibm_db" gem here: http://rubyforge.org/projects/rubyibm/

N.B. The unwarranted license of DB2 Express-C is currently limited to using 2 processor cores & 2 GB of memory. However, it's still a better option than "Oracle XE".

Starting from scratch...

No comments: