[armedbear-devel] Connection to database via JDBC and classpath

Alex Mizrahi alex.mizrahi at gmail.com
Fri May 18 12:54:51 UTC 2012

>> I've got it working once using something like java:jclass in SLIME 
>> REPL, but not it doesn't seem to work (in a slightly different 
>> environment).
>> Note that if jar is added to classpath via java commandline 
>> Class.forName will work fine. That's probably the easiest way to get 
>> it working.
>> Only loading jar dynamically via classloader is a problem.
> I've also tried that. Started ABCL with 'java -cp $JDBC_JAR abcl.jar' 
> and Class.forName still didn't work. Am I missing some parameter?

It looks like you can't use both -cp and -jar.

Here's what works for me:

$ java -cp abcl.jar:postgresql.jdbc3.jar org.armedbear.lisp.Main

Armed Bear Common Lisp 1.0.1-svn-13932
Java 1.6.0_20 Sun Microsystems Inc.
OpenJDK 64-Bit Server VM
Low-level initialization completed in 1.024 seconds.
Startup completed in 3.393 seconds.
Type ":help" for a list of available commands.

CL-USER(1): (jstatic "forName" "java.lang.Class"  "org.postgresql.Driver")
#<java.lang.Class class org.postgresql.Driver {218C6982}>

CL-USER(6): (java:jstatic "getConnection" "java.sql.DriverManager" 
"jdbc:postgresql:jena_test" "alex" "xxxxxx")
org.postgresql.jdbc3.Jdbc3Connec.... {4FC0CB76}>

So, I specify both postgresql and abcl jars in -cp and load class 
org.armedbear.lisp.Main (it starts interpreter and repl).
Then, well, it works. I use older version of PostgreSQL driver, but I 
think it doesn't really matter.


More information about the armedbear-devel mailing list