What is the best way to launch HSQLDB for unit testing, when working with spring, maven and hibernate?

tom eustace picture tom eustace · Jun 16, 2010 · Viewed 16.3k times · Source

In my project I can successfully test database code. I'm using Spring, Hibernate, HSQLDB, JUnit and Maven.

The catch is that currently I have to launch HSQLDB manually prior to running the tests. What is the best way to automate the launching of HSQLDB with the technologies being used?

Answer

Juha Syrjälä picture Juha Syrjälä · Jun 16, 2010

I am assuming that with hsql you are referring to HSQLDB.

Configure your database url for JDBC drivers (for hibernate etc) to embedded memory based version of HSQLDB:

jdbc:hsqldb:mem:myunittests

Then a inprocess version of HSQLDB automatically starts that stores stuff to memory. No need to start any external servers.