java.lang.ClassNotFoundException:org.apache.derby.jdbc.ClientDriver [英] java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
问题描述
我是这个网站的新手.
我在连接到我创建的Java DB时遇到了麻烦.我使用了以下代码,但给出了
I've been having trouble connecting to my Java DB I have created. I've used the following code but given
java.lang.ClassNotFoundException:org.apache.derby.jdbc.ClientDriver
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
作为错误.
String url = "jdbc:derby://localhost:1527/db;create=true;user=Administrator";
String driver = "org.apache.derby.jdbc.ClientDriver";
// login and connection details above
try {
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
conn = DriverManager.getConnection(url);
Statement s = conn.createStatement();
System.out.println("connected!");
} catch (ClassNotFoundException | SQLException e) {
JOptionPane.showMessageDialog(null, "error in dbConnection " + e);
System.out.println(e.toString());
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error in DBconnection , consult developers!");
}
我尝试过许多论坛和供稿,但给出的建议似乎都无效.
I've tried going through many forums and feeds and none of the advice given seems to work.
推荐答案
您缺少 JAR
,其中包含类 org.apache.derby.jdbc.ClientDriver
这是 derbyclient.jar
You're missing the JAR
which contains the class org.apache.derby.jdbc.ClientDriver
which is derbyclient.jar
您可以从或者,如果您使用Maven进行构建,则可以将以下内容添加到您的 pom.xml
Or, If you're using maven for building, you can add the following to your pom.xml
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.14.1.0</version>
</dependency>
这篇关于java.lang.ClassNotFoundException:org.apache.derby.jdbc.ClientDriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!