Reputation: 2030
I have a HSQLDB 1.8 in form of a mydata.properties and mydata.script. In mydata.script, there are some basic SQL statements to create the schema and populate the db.
When I use a standard Java JDBC call to load this database, I noticed that on the filesystem, the following seemingly happens:
How can I prevent mydata.script from being deleted? Is this normal HSQLDB behavior?
I would like mydata.script to persist (with its timestamp) at all times in the filesystem, it is meant as a read-only datasource.
EDIT: The manual does state that this is default behavior in Appendix C. In my use case, multiple programs (not only Java) read this db. If a program attempts reads to the .script file for the first time, just while it is being deleted because of first access of another program, it will cause errors.
EDIT2: If above is indeed not possible, is there not a way to transform this mydata.script (that contains all SQL calls) to some binary HSQLDB blob format that is just loaded through JDBC and not modified?
Upvotes: 0
Views: 427
Reputation: 24352
You can access a readonly HSQLDB database simultaneously from multiple processes. Add this line to the properties file to make the database readonly:
readonly=yes
Upvotes: 1
Reputation: 2030
I found an answer to my question: There is a modified
attribute that when set to no
in a HSQLDB .properties file will prevent the behavior observed in my question.
Upvotes: 0
Reputation: 123409
Based on your usage case, HSQLDB is probably not the right tool for the job.
It sounds like you want to access the database in-process from multiple applications, but HSQLDB does not support that. From the "Managing Database Connections" section of the Deployment Guide:
In all running modes (server or in-process) multiple connections to the database engine are supported. in-process (standalone) mode supports connections from the client in the same Java Virtual Machine,
So, if you want multiple concurrent connections from separate processes you should be using HSQLDB in "server" mode, but you likely don't want to be bothered with that.
Also, HSQLDB is tightly bound to Java so if you have non-Java applications that want access to the data you are probably making your life harder than it needs to be.
Another database format, possibly SQLite, might work better for you.
Upvotes: 1