Class DbStarter

  • All Implemented Interfaces:
    java.util.EventListener, javax.servlet.ServletContextListener

    public class DbStarter
    extends java.lang.Object
    implements javax.servlet.ServletContextListener
    This class can be used to start the H2 TCP server (or other H2 servers, for example the PG server) inside a web application container such as Tomcat or Jetty. It can also open a database connection.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.sql.Connection conn  
      private Server server  
    • Constructor Summary

      Constructors 
      Constructor Description
      DbStarter()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void contextDestroyed​(javax.servlet.ServletContextEvent servletContextEvent)  
      void contextInitialized​(javax.servlet.ServletContextEvent servletContextEvent)  
      java.sql.Connection getConnection()
      Get the connection.
      private static java.lang.String getParameter​(javax.servlet.ServletContext servletContext, java.lang.String key, java.lang.String defaultValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • conn

        private java.sql.Connection conn
      • server

        private Server server
    • Constructor Detail

      • DbStarter

        public DbStarter()
    • Method Detail

      • contextInitialized

        public void contextInitialized​(javax.servlet.ServletContextEvent servletContextEvent)
        Specified by:
        contextInitialized in interface javax.servlet.ServletContextListener
      • getParameter

        private static java.lang.String getParameter​(javax.servlet.ServletContext servletContext,
                                                     java.lang.String key,
                                                     java.lang.String defaultValue)
      • getConnection

        public java.sql.Connection getConnection()
        Get the connection.
        Returns:
        the connection
      • contextDestroyed

        public void contextDestroyed​(javax.servlet.ServletContextEvent servletContextEvent)
        Specified by:
        contextDestroyed in interface javax.servlet.ServletContextListener