JRuby

java.lang.NullPointerException when trying to connect to a Oracle XE database

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1RC1
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    ruby 1.8.6 (2008-01-07 rev 5512) [sparc-jruby1.1RC1], activerecord-jdbc-adapter (0.7.1)
  • Number of attachments :
    1

Description

When attempting to connect to a DB2 database, I get the following error:

/usr/local/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.7.1/lib/active_record/connection_adapters/jdbc_adapter.rb:303:in `initialize': The driver encountered an error: java.lang.NullPointerException: null (RuntimeError)
from /usr/local/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.7.1/lib/active_record/connection_adapters/jdbc_adapter.rb:46:in `new'
from /usr/local/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.7.1/lib/active_record/connection_adapters/jdbc_adapter.rb:46:in `jdbc_connection'
from /usr/local/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection='
from /usr/local/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection'
from /usr/local/jruby-1.1RC1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
from ./rowcounts.rb:13

The script I am running is this:

require 'rubygems'
gem 'activerecord-jdbc-adapter'
require 'jdbc_adapter'
require 'active_record'

ActiveRecord::Base.establish_connection(
:adapter => 'jdbc',
:driver => 'COM.ibm.db2.jdbc.app.DB2Driver',
:url => 'jdbc:db2:OSU',
:username => 'db2inst1',
:password => 'db2admin'
)
conn = ActiveRecord::Base.connection
puts conn.active?

Under ruby 1.8.5 (2007-11-01 rev 4842) [sparc-jruby1.1b1], activerecord-jdbc-adapter (0.7.1), i also error out with this message:

java.lang.NoSuchMethodError: org.jruby.javasupport.JavaEmbedUtils.newObjectAdapter()Lorg/jruby/RubyObjectAdapter;
[snipped 730 line stack tace, see attached file for full stack trace]

It works as expected under ruby 1.8.5 (2007-11-01 rev 4842) [sparc-jruby1.1b1], activerecord-jdbc-adapter (0.6)

Activity

Hide
Ralf Sigmund added a comment -

Despite the misleading Description above I am experiencing Null Pointer Exceptions when I try to use Rails 2.0.2 with an Oracle XE Database.

database.yml contains:

development:
adapter: jdbc
driver: oracle.jdbc.driver.OracleDriver
database: jdbc:oracle:thin:@localhost:1521:xe
username: rubyweblog_development
password: xxx

Show
Ralf Sigmund added a comment - Despite the misleading Description above I am experiencing Null Pointer Exceptions when I try to use Rails 2.0.2 with an Oracle XE Database. database.yml contains: development: adapter: jdbc driver: oracle.jdbc.driver.OracleDriver database: jdbc:oracle:thin:@localhost:1521:xe username: rubyweblog_development password: xxx
Hide
Michael Teter added a comment -

(I registered here just to reply to this topic with what I think is a solution to Ralf's problem)

I had the same NullPointerException, so I went digging in the jdbc_adapter.rb and discovered that in the function "configure_jdbc", it uses:
driver
user
pass
url

There's no use of "database" - it wants "url" instead.

Here's my (now working) database.yml

development:
adapter: jdbc
driver: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@myOracleHost:1521:mySID
username: bob
password: pass

Good luck!

Show
Michael Teter added a comment - (I registered here just to reply to this topic with what I think is a solution to Ralf's problem) I had the same NullPointerException, so I went digging in the jdbc_adapter.rb and discovered that in the function "configure_jdbc", it uses: driver user pass url There's no use of "database" - it wants "url" instead. Here's my (now working) database.yml development: adapter: jdbc driver: oracle.jdbc.OracleDriver url: jdbc:oracle:thin:@myOracleHost:1521:mySID username: bob password: pass Good luck!
Hide
Thomas E Enebo added a comment -

This issue is quite old and last commenter noticed that 'database:' should be 'url:'. Optimistically Resolving.

Show
Thomas E Enebo added a comment - This issue is quite old and last commenter noticed that 'database:' should be 'url:'. Optimistically Resolving.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: