Monday, January 12, 2009

Ruby and DB2

The next step is my Ruby adventure is to use DB2 as the data source. This will allow to plug RoR to many applications that have DB2 as the backend.

* Some instructions on how to download the DB2 driver is described at: http://wiki.rubyonrails.org/rails/pages/IBM+DB2

* After that, let me try to scaffold a DB2-based application: Tivoli Process Automation Engine

* cd ~/Rails
* mkdir TPAE
* cd TPAE
* rails tpae
* cd tpae/config
* vi database.yml

development:
adapter: ibm_db
database: maxdb71
username: maximo
password: itsmswat
schema: maximo
host: ismdbserver.tivlab.raleigh.ibm.com
port: 50005


* rake db:migrate --trace
* It failed with the following message:
Failed to connect to the [maxdb71] due to:
* It seems the problem is related because I forgot to load the DB2 profile
* . ~db2inst1/sqllib/db2profile
* rake db:migrate --trace
* I got a different problem:
Failed to connect to the [maxdb71] due to: [IBM][CLI Driver] CLI0133E Option type out of range. SQLSTATE=HY092 SQLCODE=-99999
* export LIBPATH=/home/db2inst1/sqllib/lib
* It seems I need to read some instructions on http://www.alphaworks.ibm.com/tech/db2onrails. Another day.

4 comments:

Antonio Cangiano said...

Eduardo, that error is associated with older, unsupported versions of DB2. What version of DB2 are you using on the server and on the client? Also, I don't recommend that you use the Starter Toolkit on Alphaworks since it's obsolete now. Feel free to get in touch with me via IBM's email or to ask for help in the RubyForge forum.

Raph said...

Antonio, I have that same error, and it seams that the DB2 version of the database is too old. I can't update it, is there another solution?

Antonio Cangiano said...

rafa, can you at least update the client? What version of DB2 are you using? I would recommend posting your question in the Rubyforge ibm_db forum: http://rubyforge.org/forum/forum.php?forum_id=9503

Raph said...

db2level gives me this:
Informational tokens are "DB2 v9.5.0.0", "s071001", "LINUXIA3295", and Fix Pack "0"
I don't know if that's the answer of what you've asked for.
Basically there is a RoR application running on a server and using this DB2 database. It's on production now and I don't want to take the risk of breaking it.
I just wanted to test this same app on my localhost using the same DB before deploying it to another server. But I get this Option type out of range error with my ibm_db adapter. I'm using Rails 2.0.2 so I'm using ibm_db 0.9.5. I tried older and newer version of ibm_db, but still doesn't work.
I'll post on rubyforge from now on, thanks