Running a memory-only HSQLDB in server mode

In most of the project i’ve been working in we used a light-weight database like HSQLDB or H2 in the local development environment. It’s easy to set up in the build and you make yourself independent from the setup of the dev machines. Just check out the trunk and off you go.
It’s usually fine to run a file-based database but in case you have to do your development on a windows machine a file based database is really annoying. Once a process has a connection to the database it locks the file. Can’t run the app in the web server and inspect the database with squirrel at the same time.
The good thing is that HSQLDB allows you to run a memory-only database in server mode (haven’t checked H2). Start your server like this:

java -cp ./hsqldb.jar org.hsqldb.Server -database.0 mem:mydb -dbname.0 aliasdb

Instead of passing the database setup as parameters you can put them into a server.properties file which has to be in the same directory where you execute the command.

Then use this url to connect to your database:

jdbc:hsqldb:hsql://localhost/aliasdb

Tags:

Leave a Reply