我在Eclipse中遇到此错误,试图连接到我的数据库。 我看了这些建议:
SQLException: No suitable driver found for jdbc:derby://localhost:1527
但是,它们似乎都建议将derbyclient.jar包含到我的项目的构建路径中。
java.lang.NoClassDefFoundError: org/apache/derby/jdbc/ClientDriver
at datasource.DBConnection.getDBConnection(DBConnection.java:38)
我的数据库连接:
private static final String DB_CONNECTION = "jdbc:derby://localhost:1527/database;create=true";
private static Connection getDBConnection(){
try {
DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
Connection dbConnection = DriverManager.getConnection(
DB_CONNECTION, DB_USER,DB_PASSWORD);
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
System.out.println("Connection problem");
return null;
}