Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has HSQLDB some mechanism to save in-memory data to file?

Tags:

hsqldb

Has HSQLDB some mechanism for saving in-memory data to file?

As I know after the server is shutted down, all in-memory data become unaccessible. So I want to save all in-memory data to file. Unfortunately I can't use BACKUP mechanism, because it can't be applied for in-memory data.

like image 631
user850155 Avatar asked Jul 18 '11 14:07

user850155


People also ask

What is HSQLDB in-memory database?

HSQLDB (HyperSQL Database) HSQLDB is an open source project, also written in Java, representing a relational database. It follows the SQL and JDBC standards and supports SQL features such as stored procedures and triggers. It can be used in the in-memory mode, or it can be configured to use disk storage.

What is HSQLDB used for?

HSQLDB is available under a BSD license. It is used as a database and persistence engine in many open source software projects, such as descendants of OpenOffice.org Base (i.e., Apache OpenOffice Base, LibreOffice Base, etc.), and the Jitsi VoIP and video-conference client since version 2.6.

How do I connect to HSQLDB in-memory?

Because we started an in-memory instance the connection url is a memory database url that looks like jdbc:hsqldb:mem:instanceName You will not be able to connect using this url because neither the host and the port are available, instead you should use a server database url that looks like jdbc:hsqldb:hsql://host:port/ ...

What is in-memory data store?

In-memory databases are purpose-built databases that rely primarily on memory for data storage, in contrast to databases that store data on disk or SSDs. In-memory data stores are designed to enable minimal response times by eliminating the need to access disks.


2 Answers

HSQLDB databases are of different types. The all-in-memory databases do not store the data to disk. These databases have URLs in the form jdbc:hsqldb:mem:<name>.

If your database URL is in the form jdbc:hsqldb:file:<file path> and your tables are the default MEMORY tables, the data is all in memory but the changes are written to a set of disk files.

With all types of database, including all_in_memory, you can use the SQL statement SCRIPT <file path> to save the full database to a file. If you save the data to a file with the .script extension, you can open the file as a file database.

When you run a server, the URL's are used without the jdbc:hsqldb prefix, for example server.database.0=file:C:/myfile

See the guide here http://hsqldb.org/doc/2.0/guide/running-chapt.html#running_db-sect

like image 71
fredt Avatar answered Oct 11 '22 13:10

fredt


There is an SQL command for that. Try this:

SCRIPT '/tmp/data.sql'

See here for details.

like image 40
Archie Avatar answered Oct 11 '22 15:10

Archie