| Author |
DriverManager registerDriver not working
|
Alejandro Barrero
Ranch Hand
Joined: Aug 01, 2005
Posts: 273
|
|
In the following code: Class dbDriverClass = loader.loadClass(jDataSourceClassTextField.getText()); Driver driver = (Driver) dbDriverClass.newInstance(); DriverManager.registerDriver(driver); String url = "\"" + jURLTextField.getText() + "\""; Enumeration<Driver> e = DriverManager.getDrivers(); while (e.hasMoreElements()) { Driver d = e.nextElement(); System.out.println(d.toString()); } Driver d = DriverManager.getDriver(url); String user = "\"" + jUserNameTextField.getText() + "\""; String password = "\"" + jPasswordTextField.getText() + "\""; Connection connection = DriverManager.getConnection(url, user, password); DriverManager.registerDriver(Driver driver) is not working. I am loading the class org.hsqldb.jdbcDriver from the jar file C:\Program Files\HSQLDB\hsqldb\lib\hsqldb.jar. and the url is "jdbc:hsqldb:hsql://localhost/xdb" but the commands Driver d = DriverManager.getDriver(url); Connection connection = DriverManager.getConnection(url, user, password); throw SQLException with message "No suitable driver". The enumeration doesn't find any registers drives either. I do not know what I am doing wrong. Please help. Alejandro Barrero
|
Your help will be greatly appreciated,
Alejandro Barrero
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26499
|
|
Alejandro, Usually this problem is caused by the jar file not being in the classpath. Can you post the classpath?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: DriverManager registerDriver not working
|
|
|