How to open HSQLDB resource inside jar (read-only) after modularisation using DriverManager?

问题: The internal read only database is stored in its own resource-only-jar file. After modularisation the database file cannot be found by the DriverManager resulting in the fo...

问题:

The internal read only database is stored in its own resource-only-jar file. After modularisation the database file cannot be found by the DriverManager resulting in the following error message.

FATAL : 09:13:32 (830) - could not reopen database
org.hsqldb.HsqlException: Database does not exists: /database/prodsoft

I am converting our company's application from JDK8 using ANT to JDK11 using modularisation and Maven. It is developed with Eclipse. Many problems already have been fixed but for this one I cannot find a solution on my own.

I already tried to move the database files from its own project to the maven resource folder of the project Kernel where it is used. I also tried to opens database; (the resource folder) in the module-info.java of the Kernel-project.

The database files prodsoft.properties and prodsoft.script are now located in

src/main/resources/database/

The Class that runs the DriverManager is

src/main/java/de/benthin/dataaccess/DatabaseReadOnly

The hsqldb-2.4.1.jar-driver has been found successfully and is used by the 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);

回答1:

I had a look at http://hsqldb.org/ where version 2.5 was announced for the future. I think that version 2.4.1 is only compatible until Java 10 but I did not test my case with Java 9 and 10.

As workaround I will export the database at program start and delete it after usage. As soon as the new version of the hsqldb driver is available I will update this question.

  • 发表于 2019-01-09 22:45
  • 阅读 ( 209 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除