HSQLDB database set up in 60 seconds

As described on its wiki page, HSQLDB (Hyper Structured Query Language Database) is a relational database management system written in Java. It has a JDBC driver and supports a large subset of SQL-92 and SQL:2008 standards. It offers a fast, small (around 1300 kilobytes in version 2.2) database engine which offers both in-memory and disk-based tables. Embedded and server modes are available.

HSQLDB is more often used for learning purposes since it is so lightweight and easy to set up. I would not recommend using it in an enterprise production environment however. If you wish to use mysql or any other database of your choice, it should be easy to switch the configuration. We’ll get to that later. Now let’s see how to install it fast.

1. Add the HSQLDB database dependency to your pom.xml

Add the following to the list of dependencies to your pom.xml file.

<dependency>
	<groupId>hsqldb</groupId>
	<artifactId>hsqldb</artifactId>
	<version>1.8.0.10</version>
</dependency>
Don’t forget to use Maven to clean the project, and to refresh the project in Eclipse.

2. Start the Database Server.

Go into “Referenced Libraries” inside your SpringGreetings project and right click on hsqldb-1.8.0.10.jar.

Then select Run as … Java Application. Then select “Server – org.hsqldb” and hit Ok.

3. Run the Database Manager.

To access the database, right click again on hsqldb-1.8.0.10.jar and select Run as … Java Application.

Select “Database Manager – org.hsqldb.util” and you will see a window to enter the connection details:

Leave all the defaults, making sure that you enter the following:
Type: HSQL Database Engine In-Memory
Driver: org.hsqldb.jdbcDriver
URL: jdbc:hsqldb:hsql://localhost
User: sa
Password: (leave blank)

THAT’S IT!!! You can now see how you can access the database where we will be inserting data. There is no need to create tables because we will have hibernate automatically create them in the next steps.

4. Shutdown the database server.

To shutdown the database server when you are finished using it, right click again on hsqldb-1.8.0.10.jar (inside “Referenced Libraries”) and select Run as … Java Application. Select “ShutdownServer – org.hsqldb.util”

3 Comments
Jonathan wrote on 2013-10-11 at 04:25:20:
How do i create a database that has a file for persistence?


Anil Vaish wrote on 2013-05-19 at 05:10:47:
Really ...Too good for beginner...:)


Thilina wrote on 2012-08-12 at 13:07:06:
Hi, this is really helpful. Thanks. I used to start HSQLDB database server from cmd. I will also try your other tutorials.


Post a Comment

(required):