How to connect Rails to DB2

I’ve just created a page that explains how to configure the database.yml file in Rails so that it works with the IBM DB2 adapter. You can find it here.

We plan to create an extensive FAQ section on this site, where we’ll address several of the main questions that we’ve been receiving over the past few weeks.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Posted by Antonio Cangiano | June 22 2006 09:10 pm | How-to

2 Responses to “How to connect Rails to DB2”

  1. Christos Kalantzis on 18 Sep 2006 at 1:06 pm #

    “Linux/Unix users will need to set the environment with the command:

    source /home/db2inst1/sqllib/db2profile”

    If I follow that logic, this means that the Ruby application server needs either DB2 to run localy, or have at least the DB2 Runtime installs and an instance created.

    Is there a way to use this driver on an server that has no DB2 code on it (except for the driver) and connect to a remote database server?

    Thanks in advance,

    Christos Kalantzis
    Senior Database Administrator, System Administrator
    Intertrade Systems Inc.
    (450)786-8929
    christos.kalantzis@intertrade.com

  2. Alex Pitigoi on 18 Sep 2006 at 1:07 pm #

    Christos, you are correct in your understanding. At current time, the DB2 Rails Adapter (ibm_db2_adapter.rb) has a direct dependency on the DB2 Ruby driver (ibm_db2) which in turn has a similar direct dependency on the DB2 CLI driver. In DB2 version 8.x this dependency implies at least *DB2 Run-Time Client Lite* install (see *DB2 v8.x* Info Center “documentation”:http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/start/c0011426.htm).

    In “version 9.x”:http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/c0023378.htm, the *DB2 Driver for ODBC and CLI* is “available separately, installed separately, and supports a subset of the functionality of the DB2 clients”, therefore there’s a way to limit DB2 Rails Adapter dependencies only to Ruby and CLI drivers (_some_ _restrictions_ _apply_, please consult “documentation”:http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/r0024160.htm). Regards, Alex.