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 Derby connection problem... 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 "Derby connection problem..." Watch "Derby connection problem..." New topic

Derby connection problem...

james hagbard

Joined: Sep 27, 2009
Posts: 8
Hi there

I am working on a project for a class I am taking and I am having a problem with making the JDBC connection to my JavaDB aka Derby database.

At run time I am getting
could not connect
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
<snipped for brevity>
at excelfileparser.DB.dbConnect(
at excelfileparser.Main.main(

From my reading, searching and pulling my hair out, it seems that its a classpath issue.

I am using ubuntu 9.04 (Jaunty) and Netbeans

Here are the relevent lines from my .bashrc

export PATH=$PATH:/usr/share/javadb/bin/
export DERBY_HOME=/usr/share/javadb

I found the derbyclient.jar in two places



In netbeans I can make the connection to the database without any issue by using the gui tool, however, we are learning how to do this 'manually' and the boilerplate code generated by Netbeans doesn't really make this connection obvious.

Any help would be appreciated!

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965

I generally advise not to use the CLASSPATH environment setting, but to use an explicit "-classpath" switch on the command line - I find it easier to use, although that's more of a personal preference than a hard and fast rule.

The problem here is that "/home/james/SUNWappserver/javadb/lib" is a directory, and you seem to assume that jar files inside of directories will be added to the classpath. But that's not the case - you need to add the individual jar files to the classpath. Something like "CLASSPATH=.:/home/james/SUNWappserver/javadb/lib/derbyclient.jar" may do the trick.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
I think there is a better reason than "personal preference" against using a system CLASSPATH. Each application will require a different CLASSPATH entry, so the environment variable will rapidly become cluttered, and difficult to maintain. Deleting or editing part of the CLASSPATH may cause other applications to fail. If each application maintains its own CLASSPATH maintenance is much easier.
james hagbard

Joined: Sep 27, 2009
Posts: 8
I got this one figured out actually.

It was simply a setting I needed to make in NetBeans.
I feel silly...
I agree. Here's the link:
subject: Derby connection problem...
It's not a secret anymore!