ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Martin <jeff.mar...@synamic.co.uk>
Subject RE: AntClassLoader and JDBC drivers
Date Tue, 15 Aug 2000 15:59:46 GMT
Turns out loadClass is not guaranted to run static initialisers so your
supposed to use Class.forName which is but that's no use if you want to load
something via a ClassLoader. I can get them to run by creating and instance
of the class, but that's a hack as java.sql.Driver is an interface so
there's no guarantee the an empty constructor will work.

The other problem that I've come across is that the DriverManager seems to
use the ClassLoader of the calling code to load the drivers. this is where
things get really nasty. I tried to create a wrapper class which I could
load via the AntClassLoader but just ended up getting
IllegalAccessExceptions so I've given up.

If anyone can think of a way to allow the JDBC drivers to be loaded from a
classpath other than the default ant one can you let me know.

This morning just adding a classpath attribute to the sql task seemed like a
quick and easy job :o( .

Tah.

-----Original Message-----
From: Jeff Martin [mailto:jeff.martin@synamic.co.uk]
Sent: 15 August 2000 11:47
To: Ant-Dev (E-mail)
Subject: AntClassLoader and JDBC drivers


I'm trying to load JDBC drivers via the AntClassLoader the problem I'm
having is that the driver is not being registered with DriverManager.

The driver should register itself with the DriverManager when it is loaded
using a static initialiser. As far as I know it should be being run when the
class is loaded but since it's not being registered it appears it is not.

Am I right in thinking that static code should be run when the class is
loaded via AntClassLoader. If this is not the case, how can i get it to run.

Mime
View raw message