Are these java classes view by the jre thats runs Jruby? Sounds like a
classpath problemā¦
El 17/05/2013 03:50, āPerry S.ā [email protected] escribi:
Hi Perry, you need to load the driver class (right) before connecting
using DriverManager.
Assuming the class name is right do smt like: Java::JavaClass.for_name
ācom.ibm.db2j.jdbc.DB2jDriverā
Make sure you do this after the .jar files are required, yet before
connecting ā¦
please note that jar | grep only works if the driver author named
their
java.sql.Driver implementation with āDriverā in the class name.
since you mentioned 0% Java knowledge you can not expect to 100%
understand
this - itās a Java (actually JDBC) thing ā¦
scanning (and thus loading) all .jar classes for driver implementations
(which might have arbitrary names as mentioned) would certainly be a
performance hit - thereās a Java auto-discovery convention
(META-INF/java.sql.Driver text file inside the .jar) that gets around
this
itās likely that your driver does not conform with it thus the manual
loading.
enjoy Java with JRuby - itās certainly more enjoyable this way !
WARNING: Cloudscape (instance c013800d-013e-b298-9d99-00c0a801c300) is
attempting to boot the database
/Users/pedzan/Source/OPCstuff/ruby-stuff/db/OpcClientDb even though
Cloudscape (instance c013800d-013d-b6e5-23bc-0009318f4f00) may still be
active. Only one instance of Cloudscape should boot a database at a
time. Severe and non-recoverable corruption can result and may have
already occurred.
But I am pretty sure that is because they create file locks and I have a
snapshot of the DB while its open.
Now, I just need to figure out how to dump what I need but thats
probably a topic for another list.
By the way (for the next guy who might follow). I did:
jar tf lib/db2j.jar | grep Driver
to get the exact name (which Karol had predicted correctly) ā and then
changed the slashes into dots.
The thing I donāt 100% understand is why not just do this for all the
classes when the jar file is loaded? Would that be a huge performance
hit or something?
The following does not directly help and its unsolicited but if you use
Ruby Sequel which I am currently using via jdbc drivers to hook up to
Oracle and Postgres all of your load issues should go away. Furthermore,
the ruby sequel dsl is nice to work with but you can also just pass it
raw sql or a combination of. Disclaimer I have not tried this out with
Cloudscape but if thereās a jdbc driver for it , my understanding is
that it should work. May need to drop that jar under the jruby libs
directory.
On top of Karolās mentioning of performance reasonsā¦There is no nice
API
for reflectively querying all classes loaded. Jar loading possibly
could
be done via examining classpath (although classpath can change at
runtime),
but JVM can also dynamically generate classes on the fly (or even get
loaded by JNI). The ability to just auto-process all defined things is
difficult even if you ignore the performance penalty of processing
thousands of classes you probably will never consume.
-Tom
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.