Jruby, JDBC

J

justin.crawford

Howdy-
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
oracle/jdbc/driver/OracleDriver.class
oracle/jdbc/OracleDriver.class
$ java -classpath "./lib/classes12.jar" -jar
/usr/local/jruby/lib/jruby.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:in
`get_proxy_class'
from (eval):0:in `include_class'
from -:2:in `each'
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) {
System.out.println("Hi");
}
}
$ javac -classpath "lib/classes12.jar" conn_test.java
$ java -classpath ".:lib/classes12.jar" conn_test
Hi

Thanks.
-J
 
T

Thomas E Enebo

Howdy-
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
oracle/jdbc/driver/OracleDriver.class
oracle/jdbc/OracleDriver.class
$ java -classpath "./lib/classes12.jar" -jar
/usr/local/jruby/lib/jruby.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).

-Tom

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top