I'm getting very strange (or should we say "interesting") problems when doing some very straight-forward things with DriverManager.getConnection() from JRuby.
The error message I get is this (full details further down):
This is even though the driver has been registered like this:
The funny/weird thing is this: The script above works perfectly with JRuby installed as an .exe/binary (Windows/OSX). It's only when we are using jruby-complete-1.7.x.jar that this problem occurs (tested with 1.7.2 and 1.7.4, same problem with both). The full output of the above program (which is attached as a test case btw) is this:
When running with jruby.exe/jruby it gives this instead:
...so, the line "skipping: java.sql.DriverInfo" is obviously the problem. We did some research on this and found this in the DriverManager source code (http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/sql/DriverManager.java#DriverManager.getConnection%28java.lang.String%2Cjava.util.Properties%2Cjava.lang.ClassLoader%29), line 612:
It somehow seems to have to do with the ClassLoader(s) being involved. I guess the classloader is different for jruby-complete.jar vs "standard" JRuby? Are there any ways to work around this problem?
(What we did for a temporary workaround was to have a little .java file which wraps the call to DriverManager.getConnection() for us. This works fine; obviously, .jar files being loaded in JRuby are not in the same "context" or something like normal .rb code being executed. I must admit Java classloading is not my greatest strength, so maybe someone with more experience in this regard can shed further light on the matter...)
Oh, and one more word: This has nothing to do with HSQLDB, it's purely a problem with the JDBC DriverManager. This is just a simplified test case to make it reproducible/debuggable. In real life, the jt400.jar driver is being used, but it really doesn't make any difference here: they work equally well/poor in this regard.
|