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 Trouble loading the 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 "Trouble loading the driver, "ClassNotFoundException"." Watch "Trouble loading the driver, "ClassNotFoundException"." New topic

Trouble loading the driver, "ClassNotFoundException".

Tarek Khojah
Ranch Hand

Joined: Jul 21, 2007
Posts: 58
I've spent hours and hours looking for an answer, please help me on this.

I'm using HSQL and trying to connect.

First, I need to load the driver (which exists), so I use the following:


However, I keep catching the same exception, ClassNotFoundException.

What could be wrong? I already have C:\...\lib\hsqldb.jar added to my CLASSPATH.

Please help!
And Green

Joined: Sep 28, 2007
Posts: 26
Try adding C:.; to the classpath.
Tarek Khojah
Ranch Hand

Joined: Jul 21, 2007
Posts: 58
Just to be sure, when you say classpath, you mean (in Windows) to right click on "My Computer", go to "Advanced" and so on. And not just something to do in the command prompt, correct?

If it's the first case, I did that, still have the same problem.

Do the drivers or folders or compiled code or whatever have to be in certain directories/folders?

I don't understand how forName() works, it takes org.hsqldb.jdbcDriver as a String to instantiate an object, but is that a URL or something? How does the compiler know where to look for this "org.hsqldb.jdbcDriver"?
Tarek Khojah
Ranch Hand

Joined: Jul 21, 2007
Posts: 58
Ah, found a solution, turns out I need to add the .jar file to my library in my IDE.
I agree. Here's the link:
subject: Trouble loading the driver, "ClassNotFoundException".
It's not a secret anymore!