12

I am using HSQLDB in the embedded mode.

jdbc:hsqldb:file:abc\\TESTDB;

After creating the database, the folder abc has the following files:

TESTDB.lck TESTDB.script TESTDB.log TESTDB.properties

My application is working properly

But my question is which is the main database file amongst the above-listed files?

Or is the main database file stored in some other location?

Sae1962
  • 1,122
  • 15
  • 31
Vivek
  • 11,938
  • 19
  • 92
  • 127

3 Answers3

11

.script contains all the statements to create the tables, alter them and insert the data. This file is created when you use hsqldb in memory. (so I'd say this is your database) Otherwise the database is stored in .data as other people already said

.lck is the lock file by which hsqldb knows whether the database is locked by a process. Usually you have this file only while your program is running and it is automatically deleted when you stop the programm.

.log contains internal log statements of running transactions for example and some commit or rollback points.

.properties contains the properties with which hsqldb is initialized (better don't change anything there if you don't know what you are doing). This is not to be confused with and persistence unit configuration.

kind regards

peshkira
  • 6,069
  • 1
  • 33
  • 46
  • thanks peshkira. Since the tables created resides in MEMORY i think the only script file is the DB file and there is no .data file(since i am not using CACHED tables) – Vivek Jun 26 '11 at 09:56
  • 3
    In case anyone lands here and is looking for a way to get the `.data` file created (ie: to get new tables created as `CACHED`; one simply needs to add `;hsqldb.default_table_type=cached` to the `jdbc.url` connection string. – sxc731 Nov 20 '19 at 16:20
9

A file containing your actual data might not exist in your folder for various reasons - particularly if you are using in-memory or non-cached tables. HSQLDB uses the various files you found in its working folder for a variety of reasons. You can read more about their purpose here: HSQLDB Reference.

I paraphrase some of the more relevant information:

The script file contains the definition of tables and other database objects, plus the data for non-cached tables. The log file contains recent changes to the database. The data file contains the data for cached tables and the backup file is a zipped backup of the last known consistent state of the data file. All these files are essential and should never be deleted. If the database has no cached tables, the test.data and test.backup files will not be present. In addition to those files, HSQLDB database may link to any formatted text files, such as CSV lists, anywhere on the disk.

While the "test" database is operational, a test.log file is used to write the changes made to data. This file is removed at a normal SHUTDOWN. Otherwise (with abnormal shutdown) this file is used at the next startup to redo the changes. A test.lck file is also used to record the fact that the database is open. This is deleted at a normal SHUTDOWN. In some circumstances, a test.data.old is created and deleted afterwards.

Perception
  • 79,279
  • 19
  • 185
  • 195
  • Please correct. There is no testdb.data file because he has only the default MEMORY tables and no CACHED tables. Together, all his files make up the database. – fredt Jun 24 '11 at 21:29
  • I was pointing him to the file that would contain actual data, as indicated in his question. However I edited my answer to make it more clear what the various files in HSQLDB are for. – Perception Jun 25 '11 at 12:09
  • +1 for improvement. His data is in script and log files and will not go into the data file because he has only memory tables. – fredt Jun 25 '11 at 12:44
2

I think you should have a .data file after adding records to database. In the case I'm wrong here are the documentation for you:

http://hsqldb.org/doc/guide/apc.html

http://hsqldb.org/doc/guide/ch04.html

ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214