I am working with a file based hsql database in one of my projects. Right now we are testing a lot to ensure that the frontend works correctly. But due to the nature of our data and that there is no function to delete entire datasets I have to restart quite often to get rid of my test data in my database so that I can start some tests anew. To make it clear I am not talking about JUnit tests, there we reset our database after each start of JUnit tests. I talk about tests in the application itself. It is a JSF application by the way, but that shouldn't be too important for my question.
I was thinking about an action to reset the database during runtime. Something like drop the entire database and reinitialize it with the scripts we provide on server start.
I have found this post: https://stackoverflow.com/a/9918473/1337295
But unfortunately that doesn't work, some tokens in the query seem to be unknown for the database.
We configured our database this way:
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:file:testdb;shutdown=true"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:embeddedDB/embeddedDbStructure.sql"/>
<jdbc:script location="classpath:embeddedDB/embeddedDbData.sql"/>
</jdbc:initialize-database>
We use a file based database, so that we can use the database manager swing ui, which didn't seem to work with a in-memory database.
So, is it possible to reinit the database during runtime? What would be the preferred way to do so?
Thanks in advance.