user3726374
user3726374

Reputation: 605

HSQLDB persist in-memory database

I am using an in-memory hsqldb database with a JDBC driver.

Now, I am looking for a way to persist this database for reloading after application reboot. I came up with the following options:

  1. Export .script file with sql command "SCRIPT < path > " (link)
  2. Log all statements to a log file.

Option 2 works, but it seems kind of ugly in my eyes. The script export for option 1 works too, but I seem to be unable to get the .script file back into an in-memory database.

I am thankful for any advice.

Upvotes: 2

Views: 1583

Answers (1)

fredt
fredt

Reputation: 24352

The first option is correct.

After you export the database with the SCRIPT <path> statement, you can get it into an in-memory database.

You need to connect to the scripted database with a read-only file: URL

For example if you export the database to d:/dbfiles/mydb.script, you will get the mydb.script file in the named directory. To connect to this database, use file:d:/dbfiles/mydb;files_readonly=true.

There is absolutely no speed difference between the above method and a mem: database.

Upvotes: 2

Related Questions