This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Trouble loading the driver, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Trouble loading the driver, "ClassNotFoundException"." Watch "Trouble loading the driver, "ClassNotFoundException"." New topic
Author

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:

Class.forName("org.hsqldb.jdbcDriver");

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
Greenhorn

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.
 
 
subject: Trouble loading the driver, "ClassNotFoundException".
 
Similar Threads
database connection in jsp of type 4 driver
Simple Question
Servlets with JDBC connection
Using JDBC in applets
classNotFoundException for Driver