title: H2 database In memory - Init schema via Spring/Hibernate
body: <p>I have a Spring/Hibernate application with H2 database and I have a few issues with configuring H2 to run in an embedded mode (in memory):<BR><BR>
  1. I want spring to start the H2 database so I created the following Spring beans:</p>
  
  <pre><code>&lt;bean id="org.h2.tools.Server" class="org.h2.tools.Server"
          factory-method="createTcpServer" init-method="start" destroy-method="stop"&gt;
          &lt;constructor-arg value="-tcp,-tcpAllowOthers,true,-tcpPort,8043" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="org.h2.tools.Server-WebServer" class="org.h2.tools.Server"
          factory-method="createWebServer" init-method="start"&gt;
          &lt;constructor-arg value="-web,-webAllowOthers,true,-webPort,8082" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>Do I need to use the tcp server at all for in-memory use? Is this the correct configuration for in memory?</p>
  
  <p>2.With the above configuration - How can I create and init the database schema before Hibernate is started? 
  I know that HSQLDB has a URL property that states the name of the creation script. Is there a similar way here?</p>
  
  <p>Thanks for the help</p>