Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble loading the driver, "ClassNotFoundException".

 
Tarek Khojah
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding C:.; to the classpath.
 
Tarek Khojah
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, found a solution, turns out I need to add the .jar file to my library in my IDE.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic