===================================================================== README for the IBM_DB Adapter 0.9.5 and Driver 0.9.5 (2008/06/24) For ActiveRecord Version >= 1.15.5 (and Rails >= 1.2.5) ===================================================================== Supported Operating Systems ============================ - Linux 32/64 bit - Microsoft Windows 32 bit - IBM AIX 32/64 bit - HP-UX 32/64 bit - Sun Solaris 32/64 bit Supported Databases ==================== - IBM DB2 Universal Database on Linux/Unix/Windows versions 8 and 9 - Remote connections to IBM DB2 Universal Database on i5/OS versions V5R3 and V5R4. Please ensure PTF SI27358 (includes SI27250) is installed in i5/OS version 5R3 and and PTF SI27256 is installed while using i5/OS version 5R4. - Remote connections to IBM DB2 Universal Database on z/OS version 8 and 9 - Informix Dynamic Server 11.10 and beyond. Please ensure that the IBM DataServer Viper 2 client is installed. There are two alternatives for installing the IBM_DB adapter and driver: A. Installing as a Ruby gem in the Ruby runtime B. Installing as a Rails plugin in a specific Rails application runtime Note: The IBM_DB driver can also be built separately (from source) and used in direct API calls. A. Installing the IBM_DB adapter and driver as a Ruby gem ======================================================= The IBM_DB gem is an ActiveRecord adapter and requires the abstract adapter to register it in the list of RAILS_CONNECTION_ADAPTERS (active_record.rb) before it can be utilized in the Rails framework. Once registered, the IBM_DB adapter and its dependencies (ibm_db Ruby driver and the IBM Driver for ODBC and CLI) are loaded. This enables any application in the Ruby environment, including Rails, to interact with IBM data servers. 1. Windows platforms: ===================== INSTALL (as Ruby gem) To remove previous gem version (optionally): D:\>gem uninstall ibm_db Successfully uninstalled ibm_db version 0.6.0 Example: D:\>gem install ibm_db Bulk updating gem source index for: http://gems.rubyforge.org Select which gem to install for your platform (i386-mswin32) 1. ibm_db 0.6.5 (mswin32) 2. ibm_db 0.6.5 (ruby) 3. ibm_db 0.6.0 (mswin32) 4. ibm_db 0.6.0 (ruby) Running gem install ibm_db you are presented with two choices for each release (mswin32 or ruby). Choose mswin32 and the native extension (ibm_db driver) binary file for Windows is installed. TEST (simple gem install verification) Note: IBM_DB gem requires a manual step after install: add ibm_db into gems\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77) D:\NewApp>dir vendor\plugins D:\NewApp>irb irb(main):001:0> gem 'ibm_db' irb(main):002:0> require 'mswin32/ibm_db' // notice the [mswin32] in the library path irb(main):003:0> IBM_DB::connect 'sample', 'db2admin', 'secret' D:\NewApp>ruby script\console BUILD (optionally) ibm_db gem from sources (ibm_db-x.x.x.tar.gz): 1. Download source from Rubyforge http://rubyforge.org/frs/?group_id=2361 2. Build gem from specification (IBM_DB.gemspec) D:\IBM_DB_Adapter\ibm_db>gem build IBM_DB.gemspec 2. Linux and Unix platforms: ============================ INSTALL (as Ruby gem) To remove previous gem version (optionally): $ gem uninstall ibm_db Successfully uninstalled ibm_db version 0.6.0 Note: DB2 environment is required while using an arbitrary user account (other than the DB2 install user account) $ . /home/db2inst1/sqllib/db2profile $ export IBM_DB_DIR=/opt/ibm/db2/V9.1 $ export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32 $ gem install ibm_db Select which gem to install for your platform (i686-linux) 1. ibm_db 0.6.5 (mswin32) 2. ibm_db 0.6.5 (ruby) 3. ibm_db 0.6.0 (ruby) 4. ibm_db 0.6.0 (mswin32) ... Running gem install ibm_db you are presented with two choices for each release (mswin32 or ruby). Choose ruby and the native extension (ibm_db driver) is built. ... > 2 Building native extensions. This could take a while... Successfully installed ibm_db-0.6.5 Installing ri documentation for ibm_db-0.6.5... Installing RDoc documentation for ibm_db-0.6.5... TEST (simple gem install verification) Note: IBM_DB gem requires a manual step after install: add ibm_db into /gems/activerecord-1.15.3/lib/active_record.rb (Line 77) $ ls -al vendor/plugins/ $ irb irb(main):001:0> gem 'ibm_db' irb(main):002:0> require 'ibm_db' // notice the library path (different on win32, use require 'mswin32/ibm_db') irb(main):003:0> IBM_DB::connect 'sample', 'db2admin', 'secret' $ ./script/console BUILD (optionally) ibm_db gem from sources (ibm_db-x.x.x.tar.gz): 1. Download source from Rubyforge http://rubyforge.org/frs/?group_id=2361 2. Build gem from specification (IBM_DB.gemspec) $ cd IBM_DB_Adapter/ibm_db $ gem build IBM_DB.gemspec B. Installing the IBM_DB adapter and driver as a Rails plugin ============================================================= IBM_DB adapter and driver install as plugin provides support for IBM data servers within the scope of a specific and individual Rails application. Rails plugins do not offer the version management specific to Ruby gems, but does provide an initialization mechanism which allows the IBM_DB plugin to self-insert into the ActiveRecord's list of supported adapters: RAILS_CONNECTION_ADAPTERS. Therefore, after installing IBM_DB as plugin in your Rails application, no manual step is required for the Rails framework to load it. 1. Windows platforms ===================== Register Repository and Query: A. Download and install Subversion (SVN) client from: http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91 Register rubyibm project as plugin source D:\NewApp>ruby script\plugin source svn://rubyforge.org/var/svn/rubyibm/trunk/IBM_DB_Adapter/ B. Accessing RubyForge repository through HTTP (no SVN client required) is NOT YET ENABLED D:\NewApp>ruby script\plugin source http://rubyibm.rubyforge.org/IBM_DB_Adapter/ LIST plugin D:\NewApp>ruby script\plugin list INSTALL (as Rails plugin) D:\NewApp>ruby script\plugin install ibm_db TEST (simple plugin install verification) Note: Make sure there's no ibm_db in gems\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77) D:\NewApp>ruby script\console 2. Linux and Unix platforms =========================== Register Repository and Query: A. Ensure Subversion (SVN) client is installed or download from: http://subversion.tigris.org/project_packages.html Register rubyibm project as plugin source $ ./script/plugin source svn://rubyforge.org/var/svn/rubyibm/trunk/IBM_DB_Adapter/ B. Accessing RubyForge repository through HTTP (no SVN client required) is NOT YET ENABLED $ ./script/plugin source http://rubyibm.rubyforge.org/IBM_DB_Adapter/ LIST plugin $ ./script/plugin list INSTALL (as Rails plugin) $ ./script/plugin install ibm_db TEST (simple plugin install verification) Note: Make sure there's no ibm_db in /gems/activerecord-1.15.3/lib/active_record.rb (Line 77) $ ./script/console Instructions for building and installing the IBM_DB driver from source ======================================================================= Building the driver manually as described below is not required if any the install alternatives above have been pursued. This manual procedure is in fact automated on Linux and UNIX platforms by the IBM_DB gem and plugin install, but is presented here only for reference, and also involves running the unit tests. Prerequisites: Install Ruby from: http://rubyforge.org Linux and Unix platforms: Note: commands may vary depending on the shell used - To setup DB2 environment while using an arbitrary user account (other than the DB2 install user account): Example: $ . /home/db2inst1/sqllib/db2profile - To configure test database: DB2 v9.x: some IBM_DB driver tests require a UTF-8 database: $ db2 CREATE DATABASE testdrv USING CODESET UTF-8 \ TERRITORY US COLLATE USING SYSTEM PAGESIZE 32768 DB2 v8.x: driver tests 195 and 52949 requires XML functionality only available in DB2 v9.x - To configure database connection parameters edit config.yaml Example: database: testdrv user: db2inst1 password: password hostname: localhost port: 50000 - To compile and link with DB2 client libraries: $ export IBM_DB_DIR=/opt/ibm/db2/V9.1 $ export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32 Windows platforms: - Install Visual C++ 2005, Platform SDK (latest), .Net SDK (latest) - Set environment: CALL "C:\Program Files\Microsoft Platform SDK for Windows Server 2005\SetEnv.Cmd" CALL "C:\Program Files\Microsoft Visual C++ Toolkit 2005\vcvars32.bat" SET LIB=%LIB%;C:\Program Files\Microsoft Visual Studio .NET 2005\Vc8\lib - To configure database connection parameters edit config.yaml Build and Execution: rake Execution of tests without compilation (must have .so in ibm_db source directory): rake onlytests Execution of a single test inside the tests directory can be done by the following: export SINGLE_RUBY_TEST=test_001.rb rake Limitations and known problems ============================== - ActiveRecord rename_column method is not supported for DB2 LUW, zOS and i5 - ActiveRecord remove_column method is not supported for DB2 zOS - The following tests from the ActiveRecord 1.15.3 test suite are expected to fail - test_limited_eager_with_multiple_order_columns - test_limited_eager_with_order - test_assign_ids_ignoring_blanks - test_build_by_new_record - test_get_ids - test_select_limited_ids_list - test_add_index - The following tests from the driver test suite are expected to fail on DB2 version 8 on Linux/Unix/Windows and Informix Dynamic Server because of missing native XML support. If you want to make use of the native XML features in DB2, please upgrade to version 9 or later - test_195.rb - test_52949.rb - The driver returns an error when you try to insert a TIMESTAMP value into a DATE column. To fix this, please ensure that the following configuration keyword PATCH2=58 is set in the COMMON section of your DB2 CLI initialization file (db2cli.ini): - set: db2 UPDATE CLI CFG FOR SECTION COMMON USING PATCH2 58 - verify: db2 GET CLI CFG FOR SECTION COMMON Please refer to http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/c0007882.htm for more information. - The behaviour of ActiveRecord::Base.find(:first) without an :order attribute can be unpredictable. The first record (i.e. the record with the minimum id) may be not be retrieved. In a relational model, the order of the rows returned is unpredictable and independent of the order of insertion. This issue may be addressed in a future release. - Rails applications on DB2 9 require the APPLHEAPSZ database configuration parameter to be set to or above 1024. You will need to set this parameter for each database for which you will be running DB2 on Rails applications. Following is the command syntax for updating the applheapsz parameter: > db2 update db cfg for using APPLHEAPSZ 1024 To enable this parameter, you need to restart your DB2 instance. - If you see connectivity issues with Informix Dynamic Server, please ensure that the server is configured to accept DRDA connections. Please refer to http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.admin.doc/admin154.htm for more information. - The following tests from the ActiveRecord 1.15.3 test suite are expected to fail on Informix Dynamic Server - test_quote - test_to_xml - test_should_calculate_grouped_by_function - test_should_calculate_grouped_by_function_with_table_alias - test_inserts_with_pre_and_suffix - test_add_table_with_decimals - test_no_limits_datatypes_IBM_DB - test_instance_update_should_quote_pkey - test_integer_columns - test_arguments_line_up - test_no_dump_errors - test_schema_dump_includes_decimal_options - IBM_DB is not supported on JRuby. As stated in the JRuby Wiki, "Basics of Getting JRuby Running": 'You may install other gems, but keep in mind that libraries with C extension dependencies will not work in JRuby.' http://www.headius.com/jrubywiki/index.php/Getting_Started The IBM_DB adapter relies on IBM_DB driver (C extension) and the IBM Driver for ODBC and CLI to access databases on IBM data servers. Alternatively, you can either use the regular C implementation of Ruby, or use ActiveRecord-JDBC adapter to access databases. - Query caching feature of ActiveRecord-2.0 not supported - When using ActiveRecord-2.1.0 it requires that ActiveRecord be patched, with the patch in the link below: http://rails.lighthouseapp.com/attachments/26975/association_preloading.diff The patch is required because, ActiveRecord 2.1.0 generates a non-standard SQL identifier,while preloading has_and_belongs_to_many associations, which standard compliant databases like DB2 do not support. The bug report, against ActiveRecord, can be found in the link below http://rails.lighthouseapp.com/projects/8994/tickets/394-patch-fixed-non-standard-sql-generated-by-preloading-has_and_belongs_to_many-associations - ActiveRecord-2.1.0 test suite changes appropriate for DB2/IDS will be updated in the next release of the gem. To Do ==== - Support ActiveRecord remove_column method for DB2 zOS version 9 Feedback ======== Your feedback is very much appreciated and expected through Rubyforge: - rubyibm project: http://rubyforge.org/projects/rubyibm/ - rubyibm forum: http://rubyforge.org/forum/?group_id=2361 - rubyibm bug reports: http://rubyforge.org/tracker/?group_id=2361 - IBM_DB developers: rubyibm-developers@rubyforge.org