我的 eclipse 中包含 mariadb-java-client-1.4.2.jar。该项目在我的 Windows 机器上完美地编译为 jar。然后,通过安装 mariadb 在 Fedora 22 机器上执行编译后的 jar 文件。但是,当尝试注册驱动程序时,会引发上述错误。有人知道如何解决吗?
这是该函数的源代码。
@Override
protected final Connection initialValue() {
try {
Class.forName("org.mariadb.jdbc.Driver"); // touch the mariadb driver
} catch (final ClassNotFoundException e) {
System.err.println("ERROR" + e);
}
try {
final Connection con = DriverManager.getConnection(
ServerConstants.SQL_URL,
ServerConstants.SQL_USER, ServerConstants.SQL_PASSWORD);
allConnections.add(con);
return con;
} catch (SQLException e) {
System.err.println("ERROR" + e);
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
就像错误状态一样,它找不到该类。这可能是由于缺少 Maria DB 驱动程序的 jar 或重复的 jar。如果您将项目打包为 Jar,那么 eclipse 不太可能包含 mariadb 驱动程序。
因此,解决问题的第一步是查找驱动程序的 jar 是否存在或添加到类路径中,或者类路径上是否存在具有相同类的另一个 jar。
| 归档时间: |
|
| 查看次数: |
22486 次 |
| 最近记录: |