I am working with a Spring MVC web application that simulates an in-memory persistence layer using a combination of Maps, Lists, etc. Obviously, a database is much more performant, so I want to use HSQLDB. I want the database to be embedded from the standpoint of being accessible only via the application and starting/stopping with the web application. But I want the data to be permanent, i.e. file-based so even if the application is restarted, the data is loaded from a file. Is there a way to achieve this?
Note (added 4/28/2015): I want this to work in the following way:
- Web application starts up
- Web application checks presence of database (file) in configured location
- If database is not available at configured location, it creates by running a provided SQL initialization script.
I added the following to my Spring configuration file:
<bean id="embeddedDataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:/usr/local/data/hsqldb/testdb" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
But I don't see any database file created at the location /usr/local/data/hsqldb/