Class WebApp

java.lang.Object
org.h2.server.web.WebApp
Direct Known Subclasses:
WebThread

public class WebApp extends Object
For each connection to a session, an object of this class is created. This class is used by the H2 Console.
  • Field Details

    • SYSTEM_SCHEMA_COMPARATOR

      private static final Comparator<DbTableOrView> SYSTEM_SCHEMA_COMPARATOR
    • server

      protected final WebServer server
      The web server.
    • session

      protected WebSession session
      The session.
    • attributes

      protected Properties attributes
      The session attributes
    • mimeType

      protected String mimeType
      The mime type of the current response.
    • cache

      protected boolean cache
      Whether the response can be cached.
    • stop

      protected boolean stop
      Whether to close the connection.
    • headerLanguage

      protected String headerLanguage
      The language in the HTTP header.
    • profiler

      private Profiler profiler
  • Constructor Details

  • Method Details

    • setSession

      void setSession(WebSession session, Properties attributes)
      Set the web session and attributes.
      Parameters:
      session - the session
      attributes - the attributes
    • processRequest

      String processRequest(String file, NetworkConnectionInfo networkConnectionInfo)
      Process an HTTP request.
      Parameters:
      file - the file that was requested
      networkConnectionInfo - the network connection information
      Returns:
      the name of the file to return to the client
    • getComboBox

      private static String getComboBox(String[] elements, String selected)
    • getComboBox

      private static String getComboBox(String[][] elements, String selected)
    • process

      private String process(String file, NetworkConnectionInfo networkConnectionInfo)
    • checkAdmin

      private boolean checkAdmin(String file)
    • adminLogin

      private String adminLogin()
    • autoCompleteList

      private String autoCompleteList()
    • admin

      private String admin()
    • adminSave

      private String adminSave()
    • tools

      private String tools()
    • adminStartTranslate

      private String adminStartTranslate()
    • adminShutdown

      protected String adminShutdown()
      Stop the application and the server.
      Returns:
      the page to display
    • index

      private String index()
    • getHistory

      private String getHistory()
    • addColumns

      private static int addColumns(boolean mainSchema, DbTableOrView table, StringBuilder builder, int treeIndex, boolean showColumnTypes, StringBuilder columnsBuilder)
    • escapeIdentifier

      private static String escapeIdentifier(String name)
    • addIndexes

      private static int addIndexes(boolean mainSchema, DatabaseMetaData meta, String table, String schema, StringBuilder buff, int treeIndex) throws SQLException
      Throws:
      SQLException
    • addTablesAndViews

      private int addTablesAndViews(DbSchema schema, boolean mainSchema, StringBuilder builder, int treeIndex) throws SQLException
      Throws:
      SQLException
    • prepareViewDefinitionQuery

      private static PreparedStatement prepareViewDefinitionQuery(Connection conn, DbContents contents)
    • addTableOrView

      private static int addTableOrView(DbSchema schema, boolean mainSchema, StringBuilder builder, int treeIndex, DatabaseMetaData meta, boolean showColumns, String indentation, boolean isOracle, boolean notManyTables, DbTableOrView table, boolean isView, PreparedStatement prep, String indentNode) throws SQLException
      Throws:
      SQLException
    • tables

      private String tables()
    • getStackTrace

      private String getStackTrace(int id, Throwable e, boolean isH2)
    • linkToSource

      private static String linkToSource(String s)
    • formatAsError

      private static String formatAsError(String s)
    • test

      private String test(NetworkConnectionInfo networkConnectionInfo)
    • getLoginError

      private String getLoginError(Exception e, boolean isH2)
      Get the formatted login error message.
      Parameters:
      e - the exception
      isH2 - if the current database is a H2 database
      Returns:
      the formatted error message
    • login

      private String login(NetworkConnectionInfo networkConnectionInfo)
    • logout

      private String logout()
    • query

      private String query()
    • query

      void query(Connection conn, String s, int i, int size, StringBuilder buff)
      Execute a query and append the result to the buffer.
      Parameters:
      conn - the connection
      s - the statement
      i - the index
      size - the number of statements
      buff - the target buffer
    • editResult

      private String editResult()
    • getMaxrows

      private int getMaxrows()
    • getResult

      private String getResult(Connection conn, int id, String sql, boolean allowEdit, boolean forceEdit)
    • executeLoop

      private String executeLoop(Connection conn, int count, String sql) throws SQLException
      Throws:
      SQLException
    • getCommandHistoryString

      private String getCommandHistoryString()
    • getParameterResultSet

      private static String getParameterResultSet(ParameterMetaData meta) throws SQLException
      Throws:
      SQLException
    • getResultSet

      private String getResultSet(String sql, ResultSet rs, boolean metadata, boolean list, boolean edit, long time, boolean allowEdit) throws SQLException
      Throws:
      SQLException
    • settingSave

      private String settingSave()
      Save the current connection settings to the properties file.
      Returns:
      the file to open afterwards
    • escapeData

      private static String escapeData(ResultSet rs, int columnIndex) throws SQLException
      Throws:
      SQLException
    • unescapeData

      private void unescapeData(String x, ResultSet rs, int columnIndex) throws SQLException
      Throws:
      SQLException
    • settingRemove

      private String settingRemove()
    • getMimeType

      String getMimeType()
      Get the current mime type.
      Returns:
      the mime type
    • getCache

      boolean getCache()
    • getSession

      WebSession getSession()
    • trace

      private void trace(String s)