title: HSQLDB embedded in Spring MVC application with file-based persistence
body: <p>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?</p>
  
  <p><strong>Note</strong> <em>(added 4/28/2015)</em>: I want this to work in the following way:</p>
  
  <ol>
  <li>Web application starts up</li>
  <li>Web application checks presence of database (file) in configured location</li>
  <li>If database is not available at configured location, it creates by running a provided SQL initialization script.</li>
  </ol>
  
  <p>I added the following to my Spring configuration file:</p>
  
  <pre><code>&lt;bean id="embeddedDataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"&gt;
      &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver" /&gt;
      &lt;property name="url" value="jdbc:hsqldb:file:/usr/local/data/hsqldb/testdb" /&gt;
      &lt;property name="username" value="sa" /&gt;
      &lt;property name="password" value="" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>But I don't see any database file created at the location <code>/usr/local/data/hsqldb/</code></p>