[armedbear-devel] Connection to database via JDBC and classpath
evenson at panix.com
Fri May 18 11:06:52 UTC 2012
On 5/18/12 12:14 , Alessio Stalla wrote:
> On Fri, May 18, 2012 at 11:20 AM, Francisco Vides Fernández
>> I intend to use ABCL in one of my projects. I've started to connectiing to a
>> postgresq database via jdbc. I've tried something like:
>> (jstatic "forName" "java.lang.Class" "org.postgresql.Driver")
>> But it always returns
>> Java exception 'java.lang.ClassNotFoundException: org.postgresql.Driver'.
>> [Condition of type JAVA-EXCEPTION]
> Or you can revert to Class.forName, but ensuring to use the overload
> that takes an explicit classloader, and feeding it the one used by
> ABCL (look in java.lisp to see how to retrieve it).
> On the long term, though, jclass really needs to take an extra
> argument to force initialization.
One might try using the JSS:NEW operator which has a slightly more
aggressive method of locating Java classes with the
[java.sql.DriverManager API], which is the preferred way of loading
JDBC drivers rather than the Class.forName() method.
For loading Oracle drivers, the following code works for me. I would
expect that it would for Postgres as well with suitable modification of
(defun ensure-driver ()
(#"registerDriver" 'java.sql.DriverManager (new *driver-class*)))
"A screaming comes across the sky. It has happened before, but there
is nothing to compare to it now."
More information about the armedbear-devel