It's not a secret anymore!*
The moose likes JDBC and the fly likes need help on dynamic loading of jdbc driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "need help on dynamic loading of jdbc driver" Watch "need help on dynamic loading of jdbc driver" New topic
Author

need help on dynamic loading of jdbc driver

Geronimo M. Hernandez
Greenhorn

Joined: Mar 16, 2009
Posts: 7
Hello,

I'm trying to use a jdbc-driver in a quite dynamic way, which means, that at application start, neither the jarfile of the driver is part of the classpath, nor the classname of the driver is known.

The loading of the jar, the classpath extension and initializing of the driver works so far.
But when I try to use that driver, I get an SQL-Exception complaining that no usable driver can be found for the url.

So I added a LogWriter to the DriverManager and I got the message, that the DriverManager is skipping my loaded driver.
My code is this:



And the output is this:


The related code-snippet from DriverManager source-file is:


Can anybody give me a helping hand about what to do, to successfully load a jdbc-driver at runtime?

kind regards

Geronimo
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Geronimo M. Hernandez wrote:The loading of the jar, the classpath extension and initializing of the driver works so far


Are you sure?



How do you load the jar?
Geronimo M. Hernandez
Greenhorn

Joined: Mar 16, 2009
Posts: 7
Hi,

thanks for your attention.

Are you sure?

If you look at the provided code snippets, you'll see, that the query of the DriverManager will be performed only if the creation of the Driver-instance was successful.

Meanwhile I got it and it works.
The DriverManager was the problem. I think, the so-called "security-question" (which I don't really understand) is anything else but security, so I wrote a replacement for the DriverManager and now the dynamic driver loading works as expected.

kind regards

Geronimo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help on dynamic loading of jdbc driver
 
Similar Threads
interview question
"Unable to load JdbcOdbc library". Help please?!
JDBC Connection Problem
Connecting To Database
Migrating from Oracle 8 to Oracle 9i JDBC Connection Problems