内部只读数据库存储在其自己的 resource-only-jar 文件中。模块化后,DriverManager 找不到数据库文件,导致以下错误消息。
FATAL : 09:13:32 (830) - could not reopen database
org.hsqldb.HsqlException: Database does not exists: /database/prodsoft
我正在使用模块化和 Maven 将我们公司的应用程序从使用 ANT 的 JDK8 转换为 JDK11。它是用 Eclipse 开发的。许多问题已经得到解决,但对于这个问题,我自己无法找到解决方案。
我已经尝试将数据库文件从它自己的项目移动到使用它的项目内核的 maven 资源文件夹中。我也尝试打开数据库;(资源文件夹)在内核项目的 module-info.java 中。
数据库文件prodsoft.properties和prodsoft.script现在位于
src/main/resources/database/
运行 DriverManager 的类是
src/main/java/de/benthin/dataaccess/DatabaseReadOnly
已成功找到hsqldb-2.4.1.jar -driver 并由 DriverManager 使用。
// ApplicationProperties.DATABASE_CONNECTION = "jdbc:hsqldb:res:database/prodsoft"
db_con = DriverManager.getConnection(
properties.getValue(ApplicationProperties.DATABASE_CONNECTION),
properties.getValue(ApplicationProperties.DATABASE_USER),
properties.getValue(ApplicationProperties.DATABASE_PASSWORD)
);
db_con.setAutoCommit(true);
db_con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
db_con.setReadOnly(true);