Topic: Installing DB2 for RoR on Ubuntu

I have sucessfully installed DB2 on Ubuntu 10.04 to be used in conjunction with my rails app. I'm not quite sure if everything is properly setup because I keep getting an error "Failed to load IBM DB2 Ruby driver" .

From irb:
irb(main):001:0> require 'ibm_db2'
LoadError: no such file to load -- ibm_db2
from (irb):1:in `require'
from (irb):1
irb(main):002:0>

I have followed the README.txt but the one thing I can't seem to figure out is the ibm_db2.so and how to compile it and where to put it. I put the ibm_db2_adapter into /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters and added RAILS_CONNECTION_ADAPTERS = %w( mysql postgresql sqlite firebird sqlserver db2 oracle sybase openbase ibm_db2 ) to the active_record.rb.

To test the initial connection, I changed the adapter in the YAML file to ibm_db and this was the output:

>> ActiveRecord::Base.connection
=> #<ActiveRecord::ConnectionAdapters::IBM_DBAdapter:0xb65de86c @security=nil, @
last_verification=0, @workstation=nil, @conn_options={3271982=>1}, @servertype=#
<ActiveRecord::ConnectionAdapters::IBM_DB2_LUW_COBRA:0xb65db07c @offset=nil, @li
mit=nil, @adapter=#<ActiveRecord::ConnectionAdapters::IBM_DBAdapter:0xb65de86c .
..>>, @set_quoted_literal_replacement=0, @handle_lobs_triggered=false, @schema="
db2inst1", @runtime=0.359535217285156, @application=nil, @pstmt_support_on=true,
@port=50000, @logger=#<ActiveSupport::BufferedLogger:0xb6d62b60 @log=#<File:/ho
me/*****/log/production.log>, @level=1, @buffer={},
@guard=#<Mutex:0xb6d58a5c>, @auto_flushing=1000>, @sql_parameter_values=[], @us
ername="db2inst1", @account=nil, @start_id=1, @authentication=nil, @host="localh
ost", @prepared_sql="SELECT * FROM nds_inis WHERE (nds_inis.key_string = ?) FET
CH FIRST 1 ROWS ONLY", @query_cache_enabled=false, @sql=[], @password="********
****", @database="*****", @app_user=nil, @timeout=0, @connection=#<IBM_DB::Connect
ion:0xb65de880>>
>>

However if I change the adapter to ibm_db2 and run the same I get 'ibm_db2_connection' : Failed to load IBM DB2 Ruby driver. (LoadError)


Any help with this would be greatly appreciated. Thanks in advance

Last edited by NDS (2011-03-11 15:46:49)