问题
![JAVADB_DRIVER_LABEL library missing][1]
I am trying to connect to a JavaDB through netbeans 8 IDE on Windows 7. i can connect it using the DB manager provided with netbeans in Services panel. But when trying to connect it through my code I get ClassNotFoundException for the org.apache.derby.jdbc.ClientDriver class.
I could not run the Apache tomcat server on my machine, so I am Using the Glassfish server 4 that comes with netbeans.
my code to connect to the DB is as follows:
String url = "jdbc:derby://localhost:1527/sample;UID=app;PWD=app";
Class.forName("org.apache.derby.jdbc.ClientDriver");
conn = DriverManager.getConnection(url);
This similar code worked with SQL server, MS Access.
回答1:
Please add your jdbc driver to the classpath of your project. It should work. Currently, the class loader is unable to load your driver class as it does it does not find it in the classpath
回答2:
Download the version of Apache Derby you need from here. Extract the zip and you should get derbyclient.jar
which has the class org.apache.derby.jdbc.ClientDriver
.
FYI : If your application runs on JDK 1.6 or higher, then you do not need to explicitly load the EmbeddedDriver. In that environment, the driver loads automatically.
回答3:
You need to add derbyclient.jar
to your classpath. You can find this jar in the download package of derby from here. This jar contains your org.apache.derby.jdbc.ClientDriver
.
For more information, see this answer : where is org.apache.derby.jdbc.ClientDriver?
来源:https://stackoverflow.com/questions/29666455/class-org-apache-derby-jdbc-clientdriver-not-found-exception