File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes URLClassLoader for loading JDBC driver... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "URLClassLoader for loading JDBC driver..." Watch "URLClassLoader for loading JDBC driver..." New topic

URLClassLoader for loading JDBC driver...

Tom Wang

Joined: May 28, 2003
Posts: 5
Hello :
I'm trying to use URLClassLoader to load JDBC driver without
setting CLASSPATH , belows are my codes:

URL v_url = new URL("http://localhost:8080/try/classes12.jar");
URLClassLoader v_classLoader = new URLClassLoader(new URL[] { v_url });
String vs_url = "jdbc racle:thin:@";
String user = "user";
String pass = "pass";
Connection conn = DriverManager.getConnection(vs_url,user,pass);

...but I keep getting the error message like this:

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at tryJDBC.createConnection(
at tryJDBC.main(

Please help....thanks.
Abdul Narayan D'souza TP

Joined: Apr 01, 2004
Posts: 10
Well u have successfully loaded the driver, otherwise u would get a
"ClassNotFound" Exception.

I guess there is a problem with your database url.
Just check it up with your driver's documentation.
Tom Wang

Joined: May 28, 2003
Posts: 5
Thanks for the reply.
I don't think the problem is because of the url, because the program above works fine if I added classes12.jar to the CLASSPATH.
I wonder if I can use URLClassLoader for loading the JDBC driver, then I won't have to copy the driver files to every users' computers...(My boss
doesn't want to use WEB...)
I agree. Here's the link:
subject: URLClassLoader for loading JDBC driver...
It's not a secret anymore!