未找到类[org.apache.derby.jdbc.ClientDriver]异常 [英] Class [org.apache.derby.jdbc.ClientDriver] not found Exception
问题描述
![缺少JAVADB_DRIVER_LABEL库] [1]
![JAVADB_DRIVER_LABEL library missing][1]
我试图通过Windows 7上的netbeans 8 IDE连接到JavaDB。我可以使用DB连接它经理在服务面板中提供了netbeans。但是当我尝试通过我的代码连接它时,我得到了org.apache.derby.jdbc.ClientDriver类的ClassNotFoundException。
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.
我无法在我的上运行Apache tomcat服务器机器,所以我使用netbeans附带的Glassfish服务器4.
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);
这个类似的代码适用于SQL服务器,MS Access。
This similar code worked with SQL server, MS Access.
推荐答案
您需要将 derbyclient.jar
添加到类路径中。您可以在此处的derby下载包中找到此jar。这个jar包含你的 org.apache.derby.jdbc.ClientDriver
。
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
.
有关更多信息,请参阅以下答案: org.apache.derby.jdbc.ClientDriver在哪里?
For more information, see this answer : where is org.apache.derby.jdbc.ClientDriver?
这篇关于未找到类[org.apache.derby.jdbc.ClientDriver]异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!