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

public Class WebApp

extends Object
Class Inheritance
Known Direct Subclasses
org.h2.server.web.WebThread
Imports
java.io.ByteArrayOutputStream, .PrintStream, .PrintWriter, .StringReader, .StringWriter, java.math.BigDecimal, java.nio.charset.StandardCharsets, java.sql.Connection, .DatabaseMetaData, .ParameterMetaData, .PreparedStatement, .ResultSet, .ResultSetMetaData, .SQLException, .Statement, .Types, java.util.ArrayList, .Arrays, .Collections, .Comparator, .HashMap, .Iterator, .Locale, .Map, .Properties, .Random, java.util.concurrent.atomic.AtomicReference, org.h2.api.ErrorCode, org.h2.bnf.Bnf, org.h2.bnf.context.DbColumn, .DbContents, .DbSchema, .DbTableOrView, org.h2.command.ParserBase, org.h2.engine.Constants, .SysProperties, org.h2.jdbc.JdbcException, org.h2.message.DbException, org.h2.security.SHA256, org.h2.tools.Backup, .ChangeFileEncryption, .ConvertTraceFile, .CreateCluster, .DeleteDbFiles, .Recover, .Restore, .RunScript, .Script, .SimpleResultSet, org.h2.util.JdbcUtils, .NetUtils, .NetworkConnectionInfo, .Profiler, .ScriptReader, .SortedProperties, .StringUtils, .Tool, .Utils, org.h2.value.DataType

For each connection to a session, an object of this class is created. This class is used by the H2 Console.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
WebApp.IndexInfo

This class represents index information for the GUI.

Field Summary

Modifier and TypeField and Description
protected Properties
attributes

The session attributes

protected boolean
cache

Whether the response can be cached.

protected String
headerLanguage

The language in the HTTP header.

protected String
mimeType

The mime type of the current response.

private Profiler
protected final WebServer
server

The web server.

protected WebSession
session

The session.

protected boolean
stop

Whether to close the connection.

private static final Comparator<DbTableOrView>

Constructor Summary

AccessConstructor and Description
pack-priv
WebApp(WebServer server)

Method Summary

Modifier and TypeMethod and Description
private static int
addColumns(boolean mainSchema, DbTableOrView table, StringBuilder builder, int treeIndex, boolean showColumnTypes, StringBuilder columnsBuilder)

private static int
addIndexes(boolean mainSchema, DatabaseMetaData meta, String table, String schema, StringBuilder buff, int treeIndex)

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, AtomicReference<PreparedStatement> prepRef, String indentNode)

private int
addTablesAndViews(DbSchema schema, boolean mainSchema, StringBuilder builder, int treeIndex)

private String
private String
private String
protected String

Returns:

the page to display
adminShutdown
()

Stop the application and the server.

private String
private String
private boolean
private String
private static String
escapeData(ResultSet rs, int columnIndex)

private static String
private String
executeLoop(Connection conn, int count, String sql)

private static String
pack-priv boolean
private static String
getComboBox(String[] elements, String selected)

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

private String
private String
private String

Returns:

the formatted error message
getLoginError
(Exception
the exception
e
,
boolean
if the current database is a H2 database
isH2
)

Get the formatted login error message.

private int
pack-priv String

Returns:

the mime type
getMimeType
()

Get the current mime type.

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

private String
getResultSet(String sql, ResultSet rs, boolean metadata, boolean list, boolean edit, long time, boolean allowEdit)

pack-priv WebSession
private String
getStackTrace(int id, Throwable e, boolean isH2)

private String
private static String
private String
login(NetworkConnectionInfo networkConnectionInfo)

private String
private static PreparedStatement
private String
process(String file, NetworkConnectionInfo networkConnectionInfo)

pack-priv String

Returns:

the name of the file to return to the client
processRequest
(String
the file that was requested
file
,
NetworkConnectionInfo
the network connection information
networkConnectionInfo
)

Process an HTTP request.

private String
pack-priv void
query(Connection
the connection
conn
,
String
the statement
s
,
int
the index
i
,
int
the number of statements
size
,
StringBuilder
the target buffer
buff
)

Execute a query and append the result to the buffer.

pack-priv void
setSession(WebSession
the session
session
,
Properties
the attributes
attributes
)

Set the web session and attributes.

private String
private String

Returns:

the file to open afterwards
settingSave
()

Save the current connection settings to the properties file.

private String
private String
test(NetworkConnectionInfo networkConnectionInfo)

private String
private void
private void
unescapeData(String x, ResultSet rs, int columnIndex)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
protected Properties attributes

The session attributes

cacheback to summary
protected boolean cache

Whether the response can be cached.

headerLanguageback to summary
protected String headerLanguage

The language in the HTTP header.

mimeTypeback to summary
protected String mimeType

The mime type of the current response.

profilerback to summary
private Profiler profiler
serverback to summary
protected final WebServer server

The web server.

sessionback to summary
protected WebSession session

The session.

stopback to summary
protected boolean stop

Whether to close the connection.

SYSTEM_SCHEMA_COMPARATORback to summary
private static final Comparator<DbTableOrView> SYSTEM_SCHEMA_COMPARATOR

Constructor Detail

WebAppback to summary
pack-priv WebApp(WebServer server)

Method Detail

addColumnsback to summary
private static int addColumns(boolean mainSchema, DbTableOrView table, StringBuilder builder, int treeIndex, boolean showColumnTypes, StringBuilder columnsBuilder)
addIndexesback to summary
private static int addIndexes(boolean mainSchema, DatabaseMetaData meta, String table, String schema, StringBuilder buff, int treeIndex) throws SQLException
addTableOrViewback to summary
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, AtomicReference<PreparedStatement> prepRef, String indentNode) throws SQLException
addTablesAndViewsback to summary
private int addTablesAndViews(DbSchema schema, boolean mainSchema, StringBuilder builder, int treeIndex) throws SQLException
adminback to summary
private String admin()
adminLoginback to summary
private String adminLogin()
adminSaveback to summary
private String adminSave()
adminShutdownback to summary
protected String adminShutdown()

Stop the application and the server.

Returns:String

the page to display

adminStartTranslateback to summary
private String adminStartTranslate()
autoCompleteListback to summary
private String autoCompleteList()
checkAdminback to summary
private boolean checkAdmin(String file)
editResultback to summary
private String editResult()
escapeDataback to summary
private static String escapeData(ResultSet rs, int columnIndex) throws SQLException
escapeIdentifierback to summary
private static String escapeIdentifier(String name)
executeLoopback to summary
private String executeLoop(Connection conn, int count, String sql) throws SQLException
formatAsErrorback to summary
private static String formatAsError(String s)
getCacheback to summary
pack-priv boolean getCache()
getComboBoxback to summary
private static String getComboBox(String[] elements, String selected)
getComboBoxback to summary
private static String getComboBox(String[][] elements, String selected)
getCommandHistoryStringback to summary
private String getCommandHistoryString()
getHistoryback to summary
private String getHistory()
getLoginErrorback to summary
private String getLoginError(Exception e, boolean isH2)

Get the formatted login error message.

Parameters
e:Exception

the exception

isH2:boolean

if the current database is a H2 database

Returns:String

the formatted error message

getMaxrowsback to summary
private int getMaxrows()
getMimeTypeback to summary
pack-priv String getMimeType()

Get the current mime type.

Returns:String

the mime type

getParameterResultSetback to summary
private static String getParameterResultSet(ParameterMetaData meta) throws SQLException
getResultback to summary
private String getResult(Connection conn, int id, String sql, boolean allowEdit, boolean forceEdit)
getResultSetback to summary
private String getResultSet(String sql, ResultSet rs, boolean metadata, boolean list, boolean edit, long time, boolean allowEdit) throws SQLException
getSessionback to summary
pack-priv WebSession getSession()
getStackTraceback to summary
private String getStackTrace(int id, Throwable e, boolean isH2)
indexback to summary
private String index()
linkToSourceback to summary
private static String linkToSource(String s)
loginback to summary
private String login(NetworkConnectionInfo networkConnectionInfo)
logoutback to summary
private String logout()
prepareViewDefinitionQueryback to summary
private static PreparedStatement prepareViewDefinitionQuery(Connection conn, DbContents contents)
processback to summary
private String process(String file, NetworkConnectionInfo networkConnectionInfo)
processRequestback to summary
pack-priv String processRequest(String file, NetworkConnectionInfo networkConnectionInfo)

Process an HTTP request.

Parameters
file:String

the file that was requested

networkConnectionInfo:NetworkConnectionInfo

the network connection information

Returns:String

the name of the file to return to the client

queryback to summary
private String query()
queryback to summary
pack-priv void query(Connection conn, String s, int i, int size, StringBuilder buff)

Execute a query and append the result to the buffer.

Parameters
conn:Connection

the connection

s:String

the statement

i:int

the index

size:int

the number of statements

buff:StringBuilder

the target buffer

setSessionback to summary
pack-priv void setSession(WebSession session, Properties attributes)

Set the web session and attributes.

Parameters
session:WebSession

the session

attributes:Properties

the attributes

settingRemoveback to summary
private String settingRemove()
settingSaveback to summary
private String settingSave()

Save the current connection settings to the properties file.

Returns:String

the file to open afterwards

tablesback to summary
private String tables()
testback to summary
private String test(NetworkConnectionInfo networkConnectionInfo)
toolsback to summary
private String tools()
traceback to summary
private void trace(String s)
unescapeDataback to summary
private void unescapeData(String x, ResultSet rs, int columnIndex) throws SQLException
org.h2.server.web back to summary

pack-priv Class WebApp.IndexInfo

extends Object
Class Inheritance

This class represents index information for the GUI.

Field Summary

Modifier and TypeField and Description
pack-priv String
columns

The indexed columns.

pack-priv String
name

The index name.

pack-priv String
type

The index type name.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

columnsback to summary
pack-priv String columns

The indexed columns.

nameback to summary
pack-priv String name

The index name.

typeback to summary
pack-priv String type

The index type name.

Constructor Detail

IndexInfoback to summary
pack-priv IndexInfo()