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 DriverManager registerDriver not working 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 "DriverManager registerDriver not working" Watch "DriverManager registerDriver not working" New topic

DriverManager registerDriver not working

Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 325
In the following code:

Class dbDriverClass = loader.loadClass(jDataSourceClassTextField.getText());
Driver driver = (Driver) dbDriverClass.newInstance();
String url = "\"" + jURLTextField.getText() + "\"";
Enumeration<Driver> e = DriverManager.getDrivers();
while (e.hasMoreElements()) {
Driver d = e.nextElement();
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
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
author & internet detective

Joined: May 26, 2003
Posts: 32062

Usually this problem is caused by the jar file not being in the classpath. Can you post the classpath?

[OCA 8 book] [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
Consider Paul's rocket mass heater.
subject: DriverManager registerDriver not working