Off the Grid
Greg Osuri

I'm a hacker and an early stage investor interested in solving common problems in the simplest way possible.


I'm also the creator of Sociaholic.com - A better way to post tweets to your facebook

   

Search

April 12th, 7:48pm 2 comments

Connecting to IBM DB2 (on a mainframe) using JRuby and Active Record (If you care)

I'm going to cut the bull crap about why JRuby is awesome and get to the point, I was trying to access an old IBM Mainframe for a batch program in JRuby and couldn't find any thing useful on the blogosphere, so I decided to share how I did it. It was pretty simple using the Active Record JDCB adapter 

Setup:

  • Mac OS 10.5
  • jruby 1.4.0 
  • ruby 1.8.6
  • activerecord (2.3.5) - gem
  • activerecord-jdbc-adapter (0.9.4, 0.9.1) - gem
  • rails (2.3.5) - gem

Step 1: Install and setup JRuby

Step 2: Install the necessary gems (rails and activerecord)

jruby -S gem install rails activerecord-jdbc-adapter

If you choose to avoid rails, you can install active record as standalone too.

Step 3: Install Drivers

Download the DB2 Type 4 JDBC Drivers and place them in the same directory as your program, you can find them in your DB2 installation. You will need the following:

  • db2jcc-9.1.jar
  • db2jcc_license_cisuz-1.0.0.jar

That's pretty much it, check out the code sample to get you started

Code:

 

Comments (2)

May 21, 2010
Frank said...
Awesome! Thanks for posting!
May 21, 2010
Greg Osuri said...
Welcome. I figured some one eventually will run into this problem :)

Leave a comment...