tags:

views:

182

answers:

2

I'm considering using HSQLDB 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.

+1  A: 

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 ...

Adamski
+1  A: 

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.

William