Package org.h2.engine
Class SysProperties
- java.lang.Object
-
- org.h2.engine.SysProperties
-
public class SysProperties extends java.lang.Object
The constants defined in this class are initialized from system properties. Some system properties are per machine settings, and others are as a last resort and temporary solution to work around a problem in the application or database engine. Also, there are system properties to enable features that are not yet fully tested or that are not backward compatible.System properties can be set when starting the virtual machine:
java -Dh2.baseDir=/temp
They can be set within the application, but this must be done before loading any classes of this database (before loading the JDBC driver):System.setProperty("h2.baseDir", "/temp");
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALLOWED_CLASSES
System propertyh2.allowedClasses
(default: *).static java.lang.String
AUTH_CONFIG_FILE
System propertyh2.authConfigFile
(default: null).static java.lang.String
BIND_ADDRESS
System propertyh2.bindAddress
(default: null).static boolean
CHECK
System propertyh2.check
(default: true for JDK/JRE, false for Android).static java.lang.String
CLIENT_TRACE_DIRECTORY
System propertyh2.clientTraceDirectory
(default: trace.db/).static int
COLLATOR_CACHE_SIZE
System propertyh2.collatorCacheSize
(default: 3 2000).static int
CONSOLE_MAX_PROCEDURES_LIST_COLUMNS
System propertyh2.consoleProcedureColumns
(default: 500).static int
CONSOLE_MAX_TABLES_LIST_COLUMNS
System propertyh2.consoleTableColumns
(default: 500).static int
CONSOLE_MAX_TABLES_LIST_INDEXES
System propertyh2.consoleTableIndexes
(default: 100).static boolean
CONSOLE_STREAM
System propertyh2.consoleStream
(default: true).static int
CONSOLE_TIMEOUT
System propertyh2.consoleTimeout
(default: 1800000).static int
DATASOURCE_TRACE_LEVEL
System propertyh2.dataSourceTraceLevel
(default: 1).static int
DELAY_WRONG_PASSWORD_MAX
System propertyh2.delayWrongPasswordMax
(default: 4000).static int
DELAY_WRONG_PASSWORD_MIN
System propertyh2.delayWrongPasswordMin
(default: 250).static boolean
ENABLE_ANONYMOUS_TLS
System propertyh2.enableAnonymousTLS
(default: true).static boolean
FORCE_AUTOCOMMIT_OFF_ON_COMMIT
System propertyh2.forceAutoCommitOffOnCommit
(default: false).private static java.lang.String
H2_BASE_DIR
static java.lang.String
H2_BROWSER
INTERNALstatic java.lang.String
H2_SCRIPT_DIRECTORY
INTERNALstatic java.lang.String
JAVA_OBJECT_SERIALIZER
System propertyh2.javaObjectSerializer
(default: null).static boolean
JAVA_SYSTEM_COMPILER
System propertyh2.javaSystemCompiler
(default: true).static int
LOB_CLIENT_MAX_SIZE_MEMORY
System propertyh2.lobClientMaxSizeMemory
(default: 1048576).static boolean
lobCloseBetweenReads
System propertyh2.lobCloseBetweenReads
(default: false).static int
MAX_FILE_RETRY
System propertyh2.maxFileRetry
(default: 16).static int
MAX_MEMORY_ROWS
System propertyh2.maxMemoryRows
(default: 40000 per GB of available RAM).static int
MAX_RECONNECT
System propertyh2.maxReconnect
(default: 3).static long
MAX_TRACE_DATA_LENGTH
System propertyh2.maxTraceDataLength
(default: 65535).static boolean
NIO_CLEANER_HACK
System propertyh2.nioCleanerHack
(default: false).static boolean
NIO_LOAD_MAPPED
System propertyh2.nioLoadMapped
(default: false).static boolean
OBJECT_CACHE
System propertyh2.objectCache
(default: true).static int
OBJECT_CACHE_MAX_PER_ELEMENT_SIZE
System propertyh2.objectCacheMaxPerElementSize
(default: 4096).static int
OBJECT_CACHE_SIZE
System propertyh2.objectCacheSize
(default: 1024).static java.lang.String
PG_DEFAULT_CLIENT_ENCODING
System propertyh2.pgClientEncoding
(default: UTF-8).static java.lang.String
PREFIX_TEMP_FILE
System propertyh2.prefixTempFile
(default: h2.temp).static int
SERVER_CACHED_OBJECTS
System propertyh2.serverCachedObjects
(default: 64).static int
SERVER_RESULT_SET_FETCH_SIZE
System propertyh2.serverResultSetFetchSize
(default: 100).static int
SOCKET_CONNECT_RETRY
System propertyh2.socketConnectRetry
(default: 16).static int
SOCKET_CONNECT_TIMEOUT
System propertyh2.socketConnectTimeout
(default: 2000).static long
SPLIT_FILE_SIZE_SHIFT
System propertyh2.splitFileSizeShift
(default: 30).static boolean
THREAD_DEADLOCK_DETECTOR
System propertyh2.threadDeadlockDetector
(default: false).static boolean
TRACE_IO
System propertyh2.traceIO
(default: false).static java.lang.String
URL_MAP
System propertyh2.urlMap
(default: null).static boolean
USE_THREAD_CONTEXT_CLASS_LOADER
System propertyh2.useThreadContextClassLoader
(default: false).static java.lang.String
USER_HOME
System propertyuser.home
(empty string if not set).
-
Constructor Summary
Constructors Modifier Constructor Description private
SysProperties()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static int
getAutoScaledForMemoryProperty(java.lang.String key, int defaultValue)
This method attempts to auto-scale some of our properties to take advantage of more powerful machines out of the box.static java.lang.String
getBaseDir()
INTERNALstatic java.lang.String
getScriptDirectory()
System propertyh2.scriptDirectory
(default: empty string).static void
setBaseDir(java.lang.String dir)
INTERNAL
-
-
-
Field Detail
-
H2_SCRIPT_DIRECTORY
public static final java.lang.String H2_SCRIPT_DIRECTORY
INTERNAL- See Also:
- Constant Field Values
-
H2_BROWSER
public static final java.lang.String H2_BROWSER
INTERNAL- See Also:
- Constant Field Values
-
USER_HOME
public static final java.lang.String USER_HOME
System propertyuser.home
(empty string if not set). It is usually set by the system, and used as a replacement for ~ in file names.
-
ALLOWED_CLASSES
public static final java.lang.String ALLOWED_CLASSES
System propertyh2.allowedClasses
(default: *). Comma separated list of class names or prefixes.
-
ENABLE_ANONYMOUS_TLS
public static final boolean ENABLE_ANONYMOUS_TLS
System propertyh2.enableAnonymousTLS
(default: true). When using TLS connection, the anonymous cipher suites should be enabled.
-
BIND_ADDRESS
public static final java.lang.String BIND_ADDRESS
System propertyh2.bindAddress
(default: null). The bind address to use.
-
CHECK
public static final boolean CHECK
System propertyh2.check
(default: true for JDK/JRE, false for Android). Optional additional checks in the database engine.
-
CLIENT_TRACE_DIRECTORY
public static final java.lang.String CLIENT_TRACE_DIRECTORY
System propertyh2.clientTraceDirectory
(default: trace.db/). Directory where the trace files of the JDBC client are stored (only for client / server).
-
COLLATOR_CACHE_SIZE
public static final int COLLATOR_CACHE_SIZE
System propertyh2.collatorCacheSize
(default: 3 2000). The cache size for collation keys (in elements). Used when a collator has been set for the database.
-
CONSOLE_MAX_TABLES_LIST_INDEXES
public static final int CONSOLE_MAX_TABLES_LIST_INDEXES
System propertyh2.consoleTableIndexes
(default: 100). Up to this many tables, the column type and indexes are listed.
-
CONSOLE_MAX_TABLES_LIST_COLUMNS
public static final int CONSOLE_MAX_TABLES_LIST_COLUMNS
System propertyh2.consoleTableColumns
(default: 500). Up to this many tables, the column names are listed.
-
CONSOLE_MAX_PROCEDURES_LIST_COLUMNS
public static final int CONSOLE_MAX_PROCEDURES_LIST_COLUMNS
System propertyh2.consoleProcedureColumns
(default: 500). Up to this many procedures, the column names are listed.
-
CONSOLE_STREAM
public static final boolean CONSOLE_STREAM
System propertyh2.consoleStream
(default: true). H2 Console: stream query results.
-
CONSOLE_TIMEOUT
public static final int CONSOLE_TIMEOUT
System propertyh2.consoleTimeout
(default: 1800000). H2 Console: session timeout in milliseconds. The default is 30 minutes.
-
DATASOURCE_TRACE_LEVEL
public static final int DATASOURCE_TRACE_LEVEL
System propertyh2.dataSourceTraceLevel
(default: 1). The trace level of the data source implementation. Default is 1 for error.
-
DELAY_WRONG_PASSWORD_MIN
public static final int DELAY_WRONG_PASSWORD_MIN
System propertyh2.delayWrongPasswordMin
(default: 250). The minimum delay in milliseconds before an exception is thrown for using the wrong user name or password. This slows down brute force attacks. The delay is reset to this value after a successful login. Unsuccessful logins will double the time until DELAY_WRONG_PASSWORD_MAX. To disable the delay, set this system property to 0.
-
DELAY_WRONG_PASSWORD_MAX
public static final int DELAY_WRONG_PASSWORD_MAX
System propertyh2.delayWrongPasswordMax
(default: 4000). The maximum delay in milliseconds before an exception is thrown for using the wrong user name or password. This slows down brute force attacks. The delay is reset after a successful login. The value 0 means there is no maximum delay.
-
JAVA_SYSTEM_COMPILER
public static final boolean JAVA_SYSTEM_COMPILER
System propertyh2.javaSystemCompiler
(default: true). Whether to use the Java system compiler (ToolProvider.getSystemJavaCompiler()) if it is available to compile user defined functions. If disabled or if the system compiler is not available, the com.sun.tools.javac compiler is used if available, and "javac" (as an external process) is used if not.
-
lobCloseBetweenReads
public static boolean lobCloseBetweenReads
System propertyh2.lobCloseBetweenReads
(default: false). Close LOB files between read operations.
-
LOB_CLIENT_MAX_SIZE_MEMORY
public static final int LOB_CLIENT_MAX_SIZE_MEMORY
System propertyh2.lobClientMaxSizeMemory
(default: 1048576). The maximum size of a LOB object to keep in memory on the client side when using the server mode.
-
MAX_FILE_RETRY
public static final int MAX_FILE_RETRY
System propertyh2.maxFileRetry
(default: 16). Number of times to retry file delete and rename. in Windows, files can't be deleted if they are open. Waiting a bit can help (sometimes the Windows Explorer opens the files for a short time) may help. Sometimes, running garbage collection may close files if the user forgot to call Connection.close() or InputStream.close().
-
MAX_RECONNECT
public static final int MAX_RECONNECT
System propertyh2.maxReconnect
(default: 3). The maximum number of tries to reconnect in a row.
-
MAX_MEMORY_ROWS
public static final int MAX_MEMORY_ROWS
System propertyh2.maxMemoryRows
(default: 40000 per GB of available RAM). The default maximum number of rows to be kept in memory in a result set.
-
MAX_TRACE_DATA_LENGTH
public static final long MAX_TRACE_DATA_LENGTH
System propertyh2.maxTraceDataLength
(default: 65535). The maximum size of a LOB value that is written as data to the trace system.
-
NIO_LOAD_MAPPED
public static final boolean NIO_LOAD_MAPPED
System propertyh2.nioLoadMapped
(default: false). If the mapped buffer should be loaded when the file is opened. This can improve performance.
-
NIO_CLEANER_HACK
public static final boolean NIO_CLEANER_HACK
System propertyh2.nioCleanerHack
(default: false). If enabled, use the reflection hack to un-map the mapped file if possible. If disabled, System.gc() is called in a loop until the object is garbage collected. See also https://bugs.openjdk.java.net/browse/JDK-4724038
-
OBJECT_CACHE
public static final boolean OBJECT_CACHE
System propertyh2.objectCache
(default: true). Cache commonly used values (numbers, strings). There is a shared cache for all values.
-
OBJECT_CACHE_MAX_PER_ELEMENT_SIZE
public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE
System propertyh2.objectCacheMaxPerElementSize
(default: 4096). The maximum size (precision) of an object in the cache.
-
OBJECT_CACHE_SIZE
public static final int OBJECT_CACHE_SIZE
System propertyh2.objectCacheSize
(default: 1024). The maximum number of objects in the cache. This value must be a power of 2.
-
PG_DEFAULT_CLIENT_ENCODING
public static final java.lang.String PG_DEFAULT_CLIENT_ENCODING
System propertyh2.pgClientEncoding
(default: UTF-8). Default client encoding for PG server. It is used if the client does not sends his encoding.
-
PREFIX_TEMP_FILE
public static final java.lang.String PREFIX_TEMP_FILE
System propertyh2.prefixTempFile
(default: h2.temp). The prefix for temporary files in the temp directory.
-
FORCE_AUTOCOMMIT_OFF_ON_COMMIT
public static boolean FORCE_AUTOCOMMIT_OFF_ON_COMMIT
System propertyh2.forceAutoCommitOffOnCommit
(default: false). Throw error if transaction's auto-commit property is true when a commit is executed.
-
SERVER_CACHED_OBJECTS
public static final int SERVER_CACHED_OBJECTS
System propertyh2.serverCachedObjects
(default: 64). TCP Server: number of cached objects per session.
-
SERVER_RESULT_SET_FETCH_SIZE
public static final int SERVER_RESULT_SET_FETCH_SIZE
System propertyh2.serverResultSetFetchSize
(default: 100). The default result set fetch size when using the server mode.
-
SOCKET_CONNECT_RETRY
public static final int SOCKET_CONNECT_RETRY
System propertyh2.socketConnectRetry
(default: 16). The number of times to retry opening a socket. Windows sometimes fails to open a socket, see bug https://bugs.openjdk.java.net/browse/JDK-6213296
-
SOCKET_CONNECT_TIMEOUT
public static final int SOCKET_CONNECT_TIMEOUT
System propertyh2.socketConnectTimeout
(default: 2000). The timeout in milliseconds to connect to a server.
-
SPLIT_FILE_SIZE_SHIFT
public static final long SPLIT_FILE_SIZE_SHIFT
System propertyh2.splitFileSizeShift
(default: 30). The maximum file size of a split file is 1L << x.
-
TRACE_IO
public static final boolean TRACE_IO
System propertyh2.traceIO
(default: false). Trace all I/O operations.
-
THREAD_DEADLOCK_DETECTOR
public static final boolean THREAD_DEADLOCK_DETECTOR
System propertyh2.threadDeadlockDetector
(default: false). Detect thread deadlocks in a background thread.
-
URL_MAP
public static final java.lang.String URL_MAP
System propertyh2.urlMap
(default: null). A properties file that contains a mapping between database URLs. New connections are written into the file. An empty value in the map means no redirection is used for the given URL.
-
USE_THREAD_CONTEXT_CLASS_LOADER
public static final boolean USE_THREAD_CONTEXT_CLASS_LOADER
System propertyh2.useThreadContextClassLoader
(default: false). Instead of using the default class loader when deserializing objects, the current thread-context class loader will be used.
-
JAVA_OBJECT_SERIALIZER
public static final java.lang.String JAVA_OBJECT_SERIALIZER
System propertyh2.javaObjectSerializer
(default: null). The JavaObjectSerializer class name for java objects being stored in column of type OTHER. It must be the same on client and server to work correctly.
-
AUTH_CONFIG_FILE
public static final java.lang.String AUTH_CONFIG_FILE
System propertyh2.authConfigFile
(default: null). authConfigFile define the URL of configuration file ofDefaultAuthenticator
-
H2_BASE_DIR
private static final java.lang.String H2_BASE_DIR
- See Also:
- Constant Field Values
-
-
Method Detail
-
setBaseDir
public static void setBaseDir(java.lang.String dir)
INTERNAL- Parameters:
dir
- base directory
-
getBaseDir
public static java.lang.String getBaseDir()
INTERNAL- Returns:
- base directory
-
getScriptDirectory
public static java.lang.String getScriptDirectory()
System propertyh2.scriptDirectory
(default: empty string). Relative or absolute directory where the script files are stored to or read from.- Returns:
- the current value
-
getAutoScaledForMemoryProperty
private static int getAutoScaledForMemoryProperty(java.lang.String key, int defaultValue)
This method attempts to auto-scale some of our properties to take advantage of more powerful machines out of the box. We assume that our default properties are set correctly for approx. 1G of memory, and scale them up if we have more.
-
-