File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
Bookmark "DriverManager registerDriver not working" Watch "DriverManager registerDriver not working" New topic
Author

DriverManager registerDriver not working

Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 302
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: 29255
    
140

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DriverManager registerDriver not working
 
Similar Threads
Two ways to get Connection object.
Problem Using DataSource and Creating Connection Pool
nullpointerexception
java.sql.SQLException: No suitable driver
mysql error