Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6641891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:51:52+00:00 2026-05-25T23:51:52+00:00

I don’t want to use it in embedded mode as I may allow other

  • 0

I don’t want to use it in embedded mode as I may allow other external applications to access it as well. And I want to execute the startup of the server at the same time as Tomcat loads my application (or just when tomcat runs for that matter). This is so that I don’t have to ask clients to manually run hsqldb with a command or script before they can put my war into tomcat and run it (to keep things simple).

I can perhaps call Server from main by sending command from Java, but this will give me a unending thread, I am not sure how to deal with that. Is there an easier tested way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:51:52+00:00Added an answer on May 25, 2026 at 11:51 pm

    According to the HSQLDB Documentation is possible start the database from Java Code:
    http://hsqldb.org/doc/2.0/guide/listeners-chapt.html#listeners_appstart-sect. So you can use a servlet for load the database when the web application is starting. The steps should be the following:

    1. Create a Servlet “InitDatabase” and put the code for start the database on the method init()

      @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);
          }
      }
      
    2. 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.

      <servlet>
          <servlet-name>InitDatabase</servlet-name>
          <servlet-class>bo.hsqltest.InitDatabase</servlet-class>
          <load-on-startup>1</load-on-startup>
      </servlet> 
      

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't like Jackson. I want to use ajax but with Google Gson. So
Don't know if I worded the question right, but basically what I want to
Don't be afraid to use any technical jargon or low-level explanations for things, please.
Don't they both have to convert to machine code at some point to execute
Don't get me wrong, I want them to get saved. But I always thought
I don't have much PHP experience and I want to know how to best
Don't ask me why but i can't use this method because I need to
Don't want to sort the entries. using this does not preserve the order as
don't know better title for this, but here's my code. I have class user
Don't be scared of the extensive code. The problem is general. I just provided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.