ActiveRecord DB2 JDBC driver error: undefined method `downcase' for 
nil:NilClass (NoMethodError)
------------------------------------------------------------------------------------------------

                 Key: JRUBY-5976
                 URL: https://jira.codehaus.org/browse/JRUBY-5976
             Project: JRuby
          Issue Type: Bug
          Components: Application Error
    Affects Versions: JRuby 1.6.3
         Environment: Windows XP, IBM DB2 on AS/400
            Reporter: Christian Nilsson
             Fix For: JRuby 1.6.3


Connecting from a windows machine to a remote DB2 database running on a 
Mainframe with AS/400 using the following code, based on code from "Using 
JRuby, Bringing Ruby to Java" book:

{code:title=activerecord.db2.rb}
require 'rubygems'
require 'active_record'

        ActiveRecord::Base.establish_connection(
          :adapter => 'jdbc',
          :driver => 'com.ibm.db2.jcc.DB2Driver',
          :url => 'jdbc:db2://<ip>:<port>/<database name>',
          :username => '<username>',
          :password => '<password>',
          :database => '<database name>'          
        )
                
p ActiveRecord::Base.connection.execute("select * from <scheme>.<table>")
{code} 

Results in the following error:
{code}
RuntimeError: The driver encountered an unknown error: undefined method 
`downcase' for nil:NilClass (NoMethodError) 
initialize at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-1.0.3-java/lib/arjdbc/jdbc/connection.rb:93
 
initialize at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-1.0.3-java/lib/arjdbc/jdbc/adapter.rb:31
 
jdbc_connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-1.0.3-java/lib/arjdbc/jdbc/connection_methods.rb:6
 
__send__ at org/jruby/RubyBasicObject.java:1690 send at 
org/jruby/RubyKernel.java:2117 
new_connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:223
 
checkout_new_connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:245
 
checkout at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:188
 
loop at org/jruby/RubyKernel.java:1419 
checkout at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:184
 
mon_synchronize at c:/jruby/lib/ruby/1.9/monitor.rb:201 
checkout at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:183
 
connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:98
 
retrieve_connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:326
 
retrieve_connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:123
 
connection at 
c:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:115
 
(root) at activerecord.db2.rb:14
{code}

Interestingly, I am able to connect to the same DB2 database using a datasource 
through a connection pool via jndi when deployed on a WebLogic app server. This 
is great but we use jruby for other standalone apps as well...

Output after running: jruby --version
jruby 1.6.3 (ruby-1.9.2-p136) (2011-07-07 965162f) (Java HotSpot(TM) Client VM 
1.6.0_21) [Windows XP-x86-java] 

Database drivers(db2jcc.jar, db2jcc_license_cisuz.jar) are located in same dir 
as activerecord.db2.rb. The same database drivers work with a Java application. 
Error originally "discovered" during database configuration in database.yml 
file for a rails web app.


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to