Search code examples
hsqldb

Starting hsqldb database programmatically


I want to programmatically start HSQLdb server. I create a runnable like below and then start it in a thread.

   Runnable hsqlRunnable = new Runnable() {
                public void run()
                {

                    HsqlProperties props = new HsqlProperties();
                    props.setProperty("server.database.0", "file:C:\Documents and Settings\BThirup\Application Data\Rockwell Automation\FactoryTalk ProductionCentre\logs\ApplicationLog\mydb;shutdown=true;");
                    props.setProperty("server.dbname.0", "xdb");
org.hsqldb.Server server = new org.hsqldb.Server();

                    try {
                        server.setProperties(props);
                    } catch (Exception e) {
                        return;
                    }

                    server.start();
}
}

I get the error: [Thread[HSQLDB Server @4db602,6,main]]: Shutting down because there are no open databases

Can anyone help point out where I am going wrong.

Thanks for helping Bala


Solution

  • As you commented, server.setTrace(true) helps in troubleshooting. So does server.setSilent(false).

    But you shouldn't create and start a Runnable to start the server. The Server class does all of that and starts the necessary threads.