Conor MacNeill wrote: > > The driver you are actually loading is a class which implements the Driver > interface, so there should be no problem in loading it and creating an > instance. This is true of the Oracle driver we use here.
It's true of most drivers, due to the Microsoft JVM, which didn't originally interpret Class.forName as requiring class initialization. (The requirement has been clarified, and later MS JVMs respect the requirement.) The workaround was Class.forName(...).newInstance(), which requires a public no-args constructor. It is not required, however, for JDBC drivers to have any public constructors at all. Java 2 has the nice Class.forName(String, boolean, ClassLoader), which is probably off-limits, alas. [EMAIL PROTECTED] wrote: > > Another approach that is useful is to get reference to class > and try to look up a non-existent method. This forces > resolution (usually). I don't see that this is required to work, either, but it seems like a reasonable followup to trying newInstance (which for most practical purposes will work). (For the pedantically inclined, my reading of 12.4.1 suggests that reflective methods should only cause class initialization when a corresponding non-reflective action would have, i.e., instance creation, method invocation, or field access.) Jeff Martin wrote: > > 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. This seems like the best by-the-book JDK 1.1-compatible approach. I'm assuming that your wrapper class just calls Class.forName. Why don't you post the code for your wrapper if you aren't happy with the workarounds. John L
