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

Mark Evenson evenson at panix.com
Fri May 18 13:08:19 UTC 2012

On May 18, 2012, at 14:54 , Alex Mizrahi wrote:

>>> 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.


Apparently the postgres-jdbc DriverManager API has problems if the
'postgresql.jar' is not on the system classpath, which doesn't seem to be true for the Oracle JDBC classes.

The following uses the getConnection() method directly on the

(add-to-classpath "/opt/local/share/java/postgresql.jar")
(jcall "connect" (jnew "org.postgresql.Driver") "jdbc:postgresql:test" (jnew "java.util.Properties"))

I would recommend using this over messing with the ABCL classpath,
as you'll have to include "extra" instructions to people to use
your interface beyond the Lisp code you ship.

P.S. The "-jar" and "-cp" options to Java are always mutually exclusive.

More information about the armedbear-devel mailing list