File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Load JDBC Driver via URLClassLoader Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Load JDBC Driver via URLClassLoader" Watch "Load JDBC Driver via URLClassLoader" New topic
Author

Load JDBC Driver via URLClassLoader

Guido Sautter
Ranch Hand

Joined: Dec 22, 2004
Posts: 142
Hi all,

I have a small problem with loading my JDBC driver. For a couple of reasons, I cannot put the jar(s) on the classpath, but in a configuration file. After reading this file, I create a URLClassLoader including all the jars that are listed in the config file. Then I call Class myDriverClass = Class.forName(<driverName>, true, myUrlClassLoader), which finds, loads and even instantiates the driver class trough the newInstance() method without the slightest problem. Only DriverManager.getConnection() keeps on throwing SQLExceptions telling me "No suitable driver" ...

Any ideas regarding how I can make the DriverManager know my driver?

Thanks for any advice,

Guido
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

This link might help you:
http://www.kfu.com/~nsayer/Java/dyn-jdbc.html


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Load JDBC Driver via URLClassLoader
 
Similar Threads
loading JDBC driver from a Jar (not in classpath)
How Add new classess to the System Classs loader.
RMIC Error: Could not find Class
Please Help! I'm going crazy! Classloader problem
Class loading