Reputation: 21
I'm trying to connect to a database using Derby in Java (using NetBeans), but I keep getting this error when I try to create a new database:
An error occurred while crating the database java.lang.ClassNotFoundException; org.apache.derby.jdbc.ClientDriver.
I've tried using Derby 10.16.1.1 and Derby 10.14.2.1.
Upvotes: 0
Views: 590
Reputation: 3454
The error message you are seeing suggests that the class org.apache.derby.jdbc.ClientDriver
is not being found by the class loader at runtime. This class is necessary for connecting to a Derby database.
There are few possible causes:
There is a comprehensive Derby documentation where you can find more information and step-by-step guides.
In order to add org.apache.derby.jdbc.ClientDriver
to your class path, you can do few things, depending on your development environment:
If you're using an IDE like NetBeans, you can add the JAR file to the project's build path by IDE UI, for example, the answers to this question explains how to do so.
If you're building your project with a build tool like Maven or Gradle, you can add the JAR file as a dependency in your project's pom.xml
file or build.gradle
file. You can read more about that approach here and here
If you're running your project from the command line, you can add the JAR file to the classpath by specifying it as a command-line argument when running your project's main class. For example, if the jar file is located in /lib/derby-jdbc.jar
, the command would be:
java -cp /lib/derby-jdbc.jar YourMainClass
Upvotes: 2