Class [org.apache.derby.jdbc.ClientDriver] not found Exception [duplicate]

家住魔仙堡 提交于 2019-12-09 03:58:21

问题


![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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!