DatabaseManagerSwing not shown Tomcat Service

Help
2012-12-03
2014-01-19
  • Lucille Wilson
    Lucille Wilson
    2012-12-03

    Upon startup of Tomcat (using cmd.exe and Tomcat's startup.bat) my code will use hibernate to create the in-memory schema, and then read the data from my postgresql database and insert it into the in memory database.  When the hsqldb in-memory database is initalized and contains all the data, a swing parameter is read and if the parameter says show the DatabaseManagerSwing, then the code calls DatabaseManagerSwing.

    The code is:

    if (hsqldbAdmin.equalsIgnoreCase("on")) {
    // This turns on the hsqldb, memory database's administration application
    org.hsqldb.util.DatabaseManagerSwing.main(new String {
      "-url",  "jdbc:hsqldb:mem:rrcacheserverdb", "-noexit"
    });
    }

    However, if we bring up Tomcat as a service the DatabaseManagerSwing is never shown.  

    What can I do about this?  I'd like to be able to view the in-memory database in order to support our customers or debug a problem.  But we always going to run Tomcat as a service.

     
  • Fred Toussi
    Fred Toussi
    2012-12-03

    I don't know.

    Try running the org.hsqldb.server.Server using the same method and see if it works and you can access the HSQLDB server with an external instance of DatabaseManagerSwing, using the jdbc:hsqldb:hsql: protocol.

    Alternatively, include the org.hsqldb.server.Servlet as a web app in your Tomcat setup and access the database via this servlet using the jdbc:hsqldb:http: protocol.

     
  • Lucille Wilson
    Lucille Wilson
    2012-12-04

    I'm having a bit of trouble parsing your comment.
    My web.xml says that my application listener is:

      <listener>
        <listener-class>myapplication.base.init.UIAppContextListener</listener-class>
      </listener>

    In myapplication.base.init.UIAppContextListener I have the following code:

    if (hsqldbAdmin.equalsIgnoreCase("on")) { // This is the parameter in swing which will turn on the hsqldb ui, so people can run sql statements.
    org.hsqldb.server.WebServer  server = new org.hsqldb.server.WebServer() ;

    server.setDatabaseName(0, "rrcacheserverdb");  // set tomcat applcation name
    server.setDatabasePath(0, "mem:rrcacheserverdb;sql.enforce_strict_size=true");
    server.setPort(9002);
    server.setNoSystemExit(false);
    server.setLogWriter(null);
    server.setErrWriter(null);
    server.start();
    }

    I added to web.xml the following:
       <listener>
        <listener-class>org.hsqldb.server.WebServer</listener-class>
      </listener>

    When I go to a browser I type any of the following and I get errors: unable to connect to page:

    jdbc:hsqldb:http://localhost:9002/rrcacheserverdb  // this is http protocol

    jdbc:hsqldb:hsql://localhost:9002/rrcacheserverdb // this was just to try it.

    http://localhost:9002/rrcacheserverdb // the usual

    What url string do I use to connect to the WebServer?  What else do I need in web.xml?  I'm looking to see a small gui so I can run some sql against the in-memory database running in the tomcat jvm.

     
  • Fred Toussi
    Fred Toussi
    2012-12-04

    You've used a method I did not suggest (WebServer), but it should work with the first URL you tried.

    The first method I suggested requires this modification:
    org.hsqldb.server.Server server = new org.hsqldb.server.Server() ;

    And I assume this one:
    <listener-class>org.hsqldb.server.Server</listener-class>

    and this connection URL:
    jdbc:hsqldb:hsql://localhost:9002/rrcacheserverdb

    Perhaps you should ask a Tomcat forum about methods to start an HSQLDB Server with Tomcat.

    My alternative suggestion should work, as it is hosting a Servlet which communicates via Tomcat's http server.

     
  • Lucille Wilson
    Lucille Wilson
    2012-12-04

    I tried the following:
    1. if (hsqldbAdmin.equalsIgnoreCase("on")) { // This is the parameter in swing which will turn on the hsqldb ui, so people can run sql statements.
    org.hsqldb.server.Server  server = new org.hsqldb.server.Server() ;

    server.setDatabaseName(0, "rrcacheserverdb");
    server.setDatabasePath(0, "mem:rrcacheserverdb;sql.enforce_strict_size=true");
    server.setPort(9002);
    server.setNoSystemExit(false);
    server.setLogWriter(null);
    server.setErrWriter(null);
    server.start();
    }
    2. web.xml:
      <listener>
        <listener-class>org.hsqldb.server.Server</listener-class>
      </listener>
        <listener>
        <listener-class>org.hsqldb.server.Servlet</listener-class>
      </listener>

    3. in the browser url line, I typed:
    jdbc:hsqldb:hsql://localhost:9002/rrcacheserverdb
    I also tried:  http://localhost:9002/rrcacheserverdb and
    jdbc:hsqldb:http://localhost:9002/rrcacheserverdb 

    4. No joy. 

    5. If I go over to the tomcat forum they'll refer me back to the hsqldb forum. 
    6. SInce I'm using an in-memory database, I have to use the same tomcat/JVM instance. So I'm afraid if I run runServer.bat I'll be invoking another in-memory database because I'll be using a second jvm.  I'm afraid if I use another webapp that just has org.hsqldb.server.Servlet in it, again that would be another jvm and another instance of an in-memory database. 
    7. The DatabaseManagerSwing seems to be a good option and works when I start up Tomcat in a cmd.exe DOS window, but not when I start tomcat as a service.  Is there anyway to get DatabaseManagerSwing to show when tomcat is run as a service? 

     
  • Fred Toussi
    Fred Toussi
    2012-12-04

    This is a Tomcat config question. The reasons for it to display or not display the DatabaseManager or to run or not to run Server are not part of HSQLDB's configuration.

    Regarding point 6, each instance of Tomcat is one virtual machine, not multiple ones. You should be able to config the HSQLDB jar to be available available to all web apps. The databases are shared.