Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Praveen Devarao
RE: DB2 & Type-2 Connections with jRuby [ reply ]  
2010-04-05 06:34
Hi Nicholas,

Please refer to the Getting started pdf http://rubyforge.org/docman/view.php/2361/10532/IBM_DB.pdf , The IBM_DB gem cannot be used with JRuby, as the IBM_DB driver is a Ruby 'C' extension.

As JRuby is concerned, users can always use the Generic JDBC adapter to connect to DB2 as mentioned in the Getting started doc and as you have illustrated here

Thanks

Praveen

By: Nicholas Aronne
RE: DB2 & Type-2 Connections with jRuby [ reply ]  
2010-04-02 16:04
After this was tested, a script was created to automate running our application.

By: Nicholas Aronne
DB2 & Type-2 Connections with jRuby [ reply ]  
2010-04-02 14:22
My colleague and I were able to get jRuby to run using DB2 type-2 connections with the native C library.

For anyone else who has been attempting to do so, I have provided our solution.

1. Catalog your DB2 database
e.g.
Database alias = MULTIDB
Database name = MULTIDB
Node name = PRODDB2
Database release level = c.00
Comment =
Directory entry type = Remote
Catalog database partition number = -1
Alternate server hostname = <hostname>
Alternate server port number = 50002

2. Enable DB2
e.g.
. /home/multicli/sqllib/db2dprofile

3. Export environment variables
e.g.
// This will ensure that we are using the DB2 32-bit native libraries
export LD_LIBRARY_PATH=/home/multicli/sqllib/lib32
// The next two exports gives the path to your instances SQLLIB and LIB paths, same as you would do in Ruby.
export IBM_DB_DIR=/home/multicli/sqllib
export IBM_DB_LIB=/home/multicli/sqllib/lib

4. Configure the database.yml
e.g.
// This is a snippet from ours, we specify using the JDBC adapter the name of our local database catalog, in this case MULTIDB (as we cataloged back in step 1).

development:
adapter: jdbc
username: user
password: pass
driver: com.ibm.db2.jcc.DB2Driver
url: jdbc:db2:MULTIDB
pool: 5
timeout: 5000

And there you have it, you will be able to use a type two connection with jRuby and this removes the dependency of IBM_DB.