Top Description Fields Constructors Methods
org.h2.server.web

public Class DbStarter

extends Object
implements ServletContextListener
Class Inheritance
All Implemented Interfaces
javax.servlet.ServletContextListener, java.util.EventListener
Imports
java.sql.Connection, .DriverManager, .Statement, javax.servlet.ServletContext, .ServletContextEvent, .ServletContextListener, org.h2.tools.Server, org.h2.util.StringUtils

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

Modifier and TypeField and Description
private Connection
private Server

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
contextDestroyed(ServletContextEvent
the ServletContextEvent containing the ServletContext that is being destroyed
servletContextEvent
)

Overrides default javax.servlet.ServletContextListener.contextDestroyed.

Receives notification that the ServletContext is about to be shut down.

public void
contextInitialized(ServletContextEvent
the ServletContextEvent containing the ServletContext that is being initialized
servletContextEvent
)

Overrides default javax.servlet.ServletContextListener.contextInitialized.

Receives notification that the web application initialization process is starting.

public Connection

Returns:

the connection
getConnection
()

Get the connection.

private static String
getParameter(ServletContext servletContext, String key, String defaultValue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connback to summary
private Connection conn
serverback to summary
private Server server

Constructor Detail

DbStarterback to summary
public DbStarter()

Method Detail

contextDestroyedback to summary
public void contextDestroyed(ServletContextEvent servletContextEvent)

Overrides default javax.servlet.ServletContextListener.contextDestroyed.

Doc from javax.servlet.ServletContextListener.contextDestroyed.

Receives notification that the ServletContext is about to be shut down.

All servlets and filters will have been destroyed before any ServletContextListeners are notified of context destruction.

Parameters
servletContextEvent:ServletContextEvent

the ServletContextEvent containing the ServletContext that is being destroyed

Annotations
@Override
contextInitializedback to summary
public void contextInitialized(ServletContextEvent servletContextEvent)

Overrides default javax.servlet.ServletContextListener.contextInitialized.

Doc from javax.servlet.ServletContextListener.contextInitialized.

Receives notification that the web application initialization process is starting.

All ServletContextListeners are notified of context initialization before any filters or servlets in the web application are initialized.

Parameters
servletContextEvent:ServletContextEvent

the ServletContextEvent containing the ServletContext that is being initialized

Annotations
@Override
getConnectionback to summary
public Connection getConnection()

Get the connection.

Returns:Connection

the connection

getParameterback to summary
private static String getParameter(ServletContext servletContext, String key, String defaultValue)