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
<snipped for brevity>
From my reading, searching and pulling my hair out, it seems that its a classpath issue.
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.
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.
Ping & DNS - updated with new look and Ping home screen widget
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.
Joined: Sep 27, 2009
I got this one figured out actually.
It was simply a setting I needed to make in NetBeans.
I feel silly...