Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to the HSQLDB Documentation is possible start the database from Java Code: <a href="http://hsqldb.org/doc/2.0/guide/listeners-chapt.html#listeners_appstart-sect">http://hsqldb.org/doc/2.0/guide/listeners-chapt.html#listeners_appstart-sect</a>. So you can use a servlet for load the database when the web application is starting. The steps should be the following:</p> <ol> <li><p>Create a Servlet "InitDatabase" and put the code for start the database on the method init()</p> <pre><code>@Override public void init() throws ServletException { super.init(); try { System.out.println("Starting Database"); HsqlProperties p = new HsqlProperties(); p.setProperty("server.database.0", "file:/opt/db/crm"); p.setProperty("server.dbname.0", "mydb"); p.setProperty("server.port", "9001"); Server server = new Server(); server.setProperties(p); server.setLogWriter(null); // can use custom writer server.setErrWriter(null); // can use custom writer server.start(); } catch (AclFormatException afex) { throw new ServletException(afex); } catch (IOException ioex) { throw new ServletException(ioex); } } </code></pre></li> <li><p>In your web.xml add the property load on start up and set it to 1. This for call to method init() when the Web Application is starting.</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;InitDatabase&lt;/servlet-name&gt; &lt;servlet-class&gt;bo.hsqltest.InitDatabase&lt;/servlet-class&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; </code></pre></li> </ol> <p>After do this the Web Application will start HSQLDB in a new Thread. For shutdown the database when the application stops you can override the method destroy() of InitServlet. In the method destroy you must execute the command "SHUTDOWN" as normal sql query (through JDBC).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload