public final class H2Helper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DEFAULT_COLLATION
Default embedded collation
|
private static java.util.logging.Logger |
log
Logger
|
Modifier | Constructor and Description |
---|---|
private |
H2Helper()
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
private static void |
createFunctionAliases(Database database,
java.util.List<java.lang.reflect.Method> funcs,
boolean overload)
Create function aliases for the given list of static methods, optionally
making the alias names unique by appending a unique number for each
overloaded method.
|
private static void |
executeDDL(java.util.List<java.lang.String> ddl,
Database database)
Execute a batch of DDL statements for the given database.
|
private static java.lang.String |
formatMethod(java.lang.reflect.Method method)
Generate a quoted method name and signature, suitable for use within a
CREATE ALIAS DDL statement.
|
private static java.util.List<java.lang.String> |
getFunctionAliases(Database database,
java.util.List<java.lang.reflect.Method> funcs,
boolean overload,
boolean register)
Get function aliases for the given list of static methods, optionally
making the alias names unique by appending a unique number for each
overloaded method.
|
static java.lang.String |
getH2Version()
Report the full H2 database version.
|
static java.util.List<java.lang.String> |
getPrepareStatements(Database database)
Get a list of database prepare DDL statements.
|
static void |
prepareDatabase(Database database)
Prepare the specified database by creating all necessary function
aliases and setting global parameters.
|
static void |
preparePermanentDatabase(Database database)
Register the function aliases with the HQL preprocessor, for the
permanent database.
|
static void |
runScript(java.sql.Connection connection,
java.io.Reader reader)
Run a script of SQL statements using the specified database connection.
|
static java.util.Properties |
setCommonInMemoryProperties(java.lang.String database,
java.util.Properties props)
Set the properties commonly needed by an in-memory, embedded H2 database into the given
properties object.
|
static void |
startMixedModeServer(java.lang.String... args)
Start a mixed mode TCP server using the specified arguments, which are passed directly to
the H2 server.
|
private static final java.util.logging.Logger log
private static final java.lang.String DEFAULT_COLLATION
private H2Helper()
public static java.lang.String getH2Version()
public static java.util.Properties setCommonInMemoryProperties(java.lang.String database, java.util.Properties props)
database
- Database name to be embedded in the connection URL.props
- Object into which to store properties.props
).public static void prepareDatabase(Database database) throws PersistenceException
The "h2.sortNullsHigh" setting was removed, as the H2 driver was already initiated at the time when this method is called, so the setting has no effect.
database
- Database to prepare.PersistenceException
- if there is any error executing DDL.public static void preparePermanentDatabase(Database database)
database
- Database to prepare.public static java.util.List<java.lang.String> getPrepareStatements(Database database)
database
- Database to prepare.public static void runScript(java.sql.Connection connection, java.io.Reader reader) throws PersistenceException
connection
- Connection to target database; caller should clean up the connection.reader
- Reader from which the script will be read.PersistenceException
- if there is any error running the script.public static void startMixedModeServer(java.lang.String... args) throws PersistenceException
args
- Arguments to be passed to the H2 server.PersistenceException
- if there is an error launching the server.private static java.util.List<java.lang.String> getFunctionAliases(Database database, java.util.List<java.lang.reflect.Method> funcs, boolean overload, boolean register)
database
- Database in which to create aliases.funcs
- List of static methods for which function aliases should be
created.overload
- true
to create unique function names for each
overloaded methodregister
- true
if the function should be registered with
the HQLPreprocessor
.private static void createFunctionAliases(Database database, java.util.List<java.lang.reflect.Method> funcs, boolean overload) throws PersistenceException
database
- Database in which to create aliases.funcs
- List of static methods for which function aliases should be
created.overload
- true
to create unique function names for each
overloaded methodPersistenceException
- if there is any error executing DDL.private static java.lang.String formatMethod(java.lang.reflect.Method method)
method
- Method which is to be mapped to a function alias.private static void executeDDL(java.util.List<java.lang.String> ddl, Database database) throws PersistenceException
ddl
- database
- PersistenceException