当我连接到应用程序中的 OracleDriver 时,一切都很好。但是当我想连接运行 JUnit 测试时,我得到了 ClassNotFoundException。我做的完全一样!
我已将 ojbc 添加到库和测试库中。
public JDBCDataStorage(boolean production) throws DataStorageException {
this.production = production;
try {
rb = (PropertyResourceBundle) PropertyResourceBundle.getBundle("app.control.database.JDBCconfig");
Class.forName(rb.getString("driver"));
} catch (ClassNotFoundException e) {
throw new DataStorageException("Something went wrong in new JDBCDataStorage()" + ": " + e.getMessage());
}
DriverManager.setLoginTimeout(3);
}