HSQLDB - hiding database structure/contents from users2009-08-24 java hsqldb
I'm considering using HSQLDB version 1.8.x in a desktop app for storing local data. From what I can see, the database is stored on disk as a number of SQL statements to create the tables, insert the data, etc.
Is there a simple way I can hide this from users? I'm don't necessarily need it to be completely encrypted, etc - I'd just like to prevent the casual user from simply opening the file and seeing the structure of the database.
You could embed your database files within a jar file and connect to them using the notation:
jdbc:hsqldb:res:<path in jar>
Check out the Advanced Topics section of the HSQLDB guide for more information on this. However, I've never tried it so am not 100% sure it will work ...
The solution I've gone with for now is to call:
db.update("SET SCRIPTFORMAT COMPRESSED;");
to store the .script file in a human-unreadable form and:
db.update("SET PASSWORD password;");
to prevent more savvy users from opening the DB using their own HSQLDB client.
Unfortunately I was not able to execute below command
db.update("SET scriptformat COMPRESSED");
And was getting this error
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: SCRIPTFORMAT
This error solved with this command
db.update("SET FILES SCRIPT FORMAT COMPRESSED");
I am using HSQLDB 2.3.3
- How do I create a Java string from the contents of a file?
- "Insert if not exists" in both MySQL and HSQLDB
- Am I crazy? Switching an established product from HSQLDB to Apache Derby
- Can't get existing table from embedded hsqldb
- HSQLDB: enable LOB compression for existing database
- How to populate an embedded database (such as hsqldb) on creation
- Create a stored procedure in HSQLDB with Spring embedded databases API
- Conditional insert as a single database transaction in HSQLDB 1.8?
- hsqldb bypass authentication: reset forgotten user and password