Configure HSQLDB in java web application

Here we will learn how to configure HSQLDB in Spring web application.

HSQLDB (HyperSQL DataBase) is the SQL relational db engine written in Java. It offers a small, fast multithreaded and transactional database engine with in-memory and disk-based tables and supports embedded and server modes. It includes tools such as a command line SQL tool and GUI query tools.

Current Release : 2.2.8 (Released January 2012)

Pre-Requisite :

JDK 1.6 (Separate download for JDK 1.5 is available)

hsqldb.jar (Included in Can be downloaded from here )

Spring JDBC 3.1 Jar

How to configure in Spring :

To configure HSQLDB, we need to add  configuration details in applicationContext.xml with other bean information.


Here schema.sql contains the detail of DB that needs to be created by HSQLDB.


To populate the newly created DB test-data.sql script would be required.

Above created datasource can be used in combination of jdbctemplate and Hibernate. This datasource can directly be injected in dao layer to work with jdbctemplate.

To work with hibernate one more configuration would be required


This session factory can now be injected in Dao layer.


Me & Jayshree Singh. Main brain behind this blog/QnA site. We have written all these article as per my personal experience. I have published it mainly to help. These articles might have some problems. So bear with me and let me know if you find any problem in any of the article. You can find me on


  1. Kaushal Pandya   •  

    Thanks for sharing nice info . really helpful as struggled 1.5 days for it

    • admin   •     Author

      Thanks for your kind words.

  2. Pingback: Java Beginners Tutorial Spring 3 mvc step-by-step tutorial for java beginners

  3. Milan   •  

    I consider this amazing post , “Java Beginners Tutorial Setup data source for HSQLDB in spring”,
    pretty interesting and also the blog post ended up being a good read.
    I appreciate it-Britt

  4. janu   •  

    I would apprecite i the details regarding the creation of database,where to create the configurations and where the session factory is injected to DAO layer?

  5. InProgress   •  

    Ty a lot for that node)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">