Search code examples
derby

Establishing a Connection to Derby


I'm trying to establish a connection to a Derby database using the code below.

static {
  try  { 
    Class.forName("org.apache.derby.jdbc.ClientDriver");
  } catch (Exception e) {e.printStackTrace();}
}

However, when I run it, I get the following error:

java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)

I understand that it cannot find the Derby driver, and is a classpath error. However, I have copied all the Derby .jar files into my project's /lib folder, and I don't understand what is missing. Help anyone?


Solution

  • Perhaps your project's lib folder isn't in the classpath.

    The error says that derbyclient.jar was not found in the classpath.