Colin, Class.forClass() is how it is being done in SQLExec.java (in the version in CVS), however, I'm not using the System classloader (ClassLoader.getSystemClassLoader()), but the AntClassLoader. I don't know if there is a way to get Class.forClass() to load a class using the AntClassLoader, but I suspect not (because I think it would create security issues). When I use the AntClassLoader to load the class, the DriverManager doesn't seem to be able to find it. I made an attempt at manually registering the Driver by calling DriverManager.registerDriver(), but that didn't seem to work either. Finally I just instantiated the driver directly, and that does work.
Julian. ----- Original Message ----- From: "Colin 't Hart" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 27, 2000 10:41 AM Subject: Re: [PATCH] Print SQL to System.out or output file > Julian writes: > > > The part I'm slightly concerned about is that I don't use the > DriverManager > > to get an instance of the driver, but instead instantiate the driver using > > either the built in class loader or the AntClassLoader depending on > whether > > or not the user specifies a classpath. > > This is actually the way that you are supposed to do it. The JDBC driver is > supposed to register itself with the DriverManager (using the > registerDriver() > method) when it is loaded. > > Another way of loading JDBC drivers is to set the "jdbc.drivers" property > with a colon-separated list of drivers (java classes) and terminated with a > semi-colon. The DriverManager starts by loading all the drivers specified > in this property. Individual drivers can be loaded by calling > Class.forName() > with the driver class name. > > -- information gleaned from Enterprise Java in a Nutshell (O'Reilly). > > Cheers, > > Colin > > > >
