Cool, thanks.
> The only problem is then doing the connection as the DriverManager will refuse to use a driver that was loaded by a different classloader.
While I was awaiting your reply, I thought I would have a go at it myself. For what it is worth, the following also works. So the "standard method" of connecting to a database (via DriverManager) seems to work now (at least for my JDBC driver).
As mentioned I'm working in Java 6.0.
// For some reason my driver is in three parts
URL jdbc1 = new URL ("file:/classpath/jars/JDBC/tdgssconfig.jar");
URL jdbc2 = new URL ("file:/classpath/jars/JDBC/tdgssjava.jar");
URL jdbc3 = new URL ("file:/classpath/jars/JDBC/terajdbc4.jar");
// Either of the following seem to work.
// ClassLoader loader = new URLClassLoader (new URL [] { path, jdbc1, jdbc2, jdbc3 }, this.getClass().getClassLoader());
ClassLoader loader = new URLClassLoader (new URL [] { path, jdbc1, jdbc2, jdbc3 });
Class jdbcClass = loader.loadClass ("com.ncr.teradata.TeraDriver");
// The following is required otherwise I get a "No suitable driver" SQLException.
Object jdbcDriver = jdbcClass.newInstance ();
Connection c = DriverManager.getConnection("jdbc:teradata://dbc/", "uid", "pass");
Statement s = c.createStatement();
ResultSet r = s.executeQuery("select * from t1;");
while (r.next()) {
System.out.println (r.getString(1) + ", " + r.getString (2));
}
r.close ();
s.close ();
c.close ();
Thanks again for your post Thomas, it really helped point me in the right direction.
Glenn Mc
> Sorry, I meant Driver.connect()
>
[quoted text clipped - 13 lines]
> Regards
> Thomas
Lew - 08 May 2008 02:38 GMT
> Cool, thanks.
Please post to Usenet in plain text, not HTML.

Signature
Lew
wizard of oz - 08 May 2008 06:15 GMT
Spoke too soon. The following code *does* work in a test project, but not my
main project. Both projects are built using NetBeans 6.0.
The only difference I can pick is that the main project is a Swing project,
whereas the test project doesn't use Swing. Thomas's use of Driver.connect
does however work as he advertised.
Thanks again for all of the replies.
> Cool, thanks.
>
[quoted text clipped - 64 lines]
> > Regards
> > Thomas