Jruby, JDBC

I’m trying to build a simple connection to Oracle using JRuby. I’m a
JRuby newbie, so my method may be quite flawed. But I cannot seem to
get JRuby to recognize jars in the classpath (demonstration below). I
wonder if anyone can see what I’m doing wrong?

$ jar -tf lib/classes12.jar | grep OracleDriver
$ java -classpath “./lib/classes12.jar” -jar
require ‘java’
include_class ‘oracle.jdbc.driver.OracleDriver’
puts ‘hi’

C:\jruby\src\builtin\javasupport.rb:258:in for_name': cannot load Java class oracle.jdbc.driver.OracleDriver (NameError) from C:\jruby\src\builtin\javasupport.rb:258:inget_proxy_class’
from (eval):0:in include_class' from -:2:ineach’
from C:\jruby\src\builtin\javasupport.rb:405:in `include_class’
from -:2

$ cat conn_test.java
import oracle.jdbc.driver.OracleDriver;
class conn_test {
public static void main (String[] args) {
$ javac -classpath “lib/classes12.jar” conn_test.java
$ java -classpath “.:lib/classes12.jar” conn_test


On Wed, 19 Jul 2006, [email protected] defenestrated me:

$ java -classpath “./lib/classes12.jar” -jar

Mixing -classpath and -jar is not allowed in Java. I recommend
using one of the wrapper scripts in ./bin in the jruby distribution:

CLASSPATH=lib/classes12.jar ./bin/jruby some_script

Any followup Java-specific JRuby questions should be done on our
jruby-user and jruby-devel mailing lists on sourceforge (though
in a very short time we will be moving to codehaus).


PS- You may be the first person to try using the JDBC active record
adapter with Oracle. Report to our lists with any progress you make.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs