| Author |
URLClassLoader for loading JDBC driver...
|
Tom Wang
Greenhorn
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 }); Class.forName("oracle.jdbc.driver.OracleDriver",true,v_classLoader); String vs_url = "jdbc racle:thin:@192.168.1.3:1521:testMyDB"; 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(DriverManager.java:532) at java.sql.DriverManager.getConnection(DriverManager.java:171) at tryJDBC.createConnection(tryJDBC.java:37) at tryJDBC.main(tryJDBC.java:135) Please help....thanks.
|
 |
Abdul Narayan D'souza TP
Greenhorn
Joined: Apr 01, 2004
Posts: 10
|
|
Tom, 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
Greenhorn
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...)
|
 |
 |
|
|
subject: URLClassLoader for loading JDBC driver...
|
|
|