# Database There is one database object per open database. The format of the meta data table is: id int, 0, objectType int, sql varchar
Methods
static void | setInitialPowerOffCount(int count)
static void | setInitialPowerOffCount(int count)
void | addDatabaseObject(Session session, DbObject obj) Add an object to the database.
void | addDatabaseObject(Session session, DbObject obj) Add an object to the database. Parameters: session - the session obj - the object to add
void | addSchemaObject(Session session, SchemaObject obj) Add a schema object to the database.
void | addSchemaObject(Session session, SchemaObject obj) Add a schema object to the database. Parameters: session - the session obj - the object to add
void | afterWriting() This method is called after updates are finished.
void | afterWriting() This method is called after updates are finished.
int | allocateObjectId() Allocate a new object id.
int | allocateObjectId() Allocate a new object id. Returns: the id
boolean | areEqual(Value a, Value b) Check if two values are equal with the current comparison mode.
boolean | areEqual(Value a, Value b) Check if two values are equal with the current comparison mode. Parameters: a - the first value b - the second value Returns: true if both objects are equal
boolean | beforeWriting() This method is called before writing to the transaction log.
boolean | beforeWriting() This method is called before writing to the transaction log. Returns: true if the call was successful and writing is allowed, false if another connection was faster
void | checkPowerOff()
void | checkPowerOff()
void | checkWritingAllowed()
void | checkWritingAllowed()
void | checkpoint() Flush all changes and open a new transaction log.
void | checkpoint() Flush all changes and open a new transaction log.
void | checkpointIfRequired() Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed.
void | checkpointIfRequired() Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed. This switches to a new transaction log and resets the change pending flag in the .lock.db file.
int | compare(Value a, Value b) Compare two values with the current comparison mode.
int | compare(Value a, Value b) Compare two values with the current comparison mode. The values may have different data types including NULL. Parameters: a - the first value b - the second value Returns: 0 if both values are equal, -1 if the first value is smaller, and 1 otherwise
int | compareTypeSafe(Value a, Value b) Compare two values with the current comparison mode.
int | compareTypeSafe(Value a, Value b) Compare two values with the current comparison mode. The values must be of the same type. Parameters: a - the first value b - the second value Returns: 0 if both values are equal, -1 if the first value is smaller, and 1 otherwise
int | compareWithNull(Value a, Value b, boolean forEquality) Compare two values with the current comparison mode.
int | compareWithNull(Value a, Value b, boolean forEquality) Compare two values with the current comparison mode. The values may have different data types including NULL. Parameters: a - the first value b - the second value forEquality - perform only check for equality (= or <>) Returns: 0 if both values are equal, -1 if the first value is smaller, 1 if the second value is larger, {@link Integer#MIN_VALUE} if order is not defined due to NULL comparison
Row | createRow(Value[] data, int memory) Create a new row for a table.
Row | createRow(Value[] data, int memory) Create a new row for a table. Parameters: data - the values memory - whether the row is in memory Returns: the created row
String | createTempFile() Create a temporary file in the database folder.
String | createTempFile() Create a temporary file in the database folder. Returns: the file name
boolean | equalsIdentifiers(String a, String b) Compare two identifiers (table names, column names,...) and verify they are equal.
boolean | equalsIdentifiers(String a, String b) Compare two identifiers (table names, column names,...) and verify they are equal. Case sensitivity depends on the configuration. Parameters: a - the first identifier b - the second identifier Returns: true if they match
void | exceptionThrown(SQLException e, String sql) This method is called after an exception occurred, to inform the database event listener (if one is set).
void | exceptionThrown(SQLException e, String sql) This method is called after an exception occurred, to inform the database event listener (if one is set). Parameters: e - the exception sql - the SQL statement
UserAggregate | findAggregate(String name) Get the user defined aggregate function if it exists, or null if not.
UserAggregate | findAggregate(String name) Get the user defined aggregate function if it exists, or null if not. Parameters: name - the name of the user defined aggregate function Returns: the aggregate function or null
Comment | findComment(DbObject object) Get the comment for the given database object if one exists, or null if not.
Comment | findComment(DbObject object) Get the comment for the given database object if one exists, or null if not. Parameters: object - the database object Returns: the comment or null
Domain | findDomain(String name) Get the domain if it exists, or null if not.
Domain | findDomain(String name) Get the domain if it exists, or null if not. Parameters: name - the name of the domain Returns: the domain or null
Role | findRole(String roleName) Get the role if it exists, or null if not.
Role | findRole(String roleName) Get the role if it exists, or null if not. Parameters: roleName - the name of the role Returns: the role or null
Schema | findSchema(String schemaName) Get the schema if it exists, or null if not.
Schema | findSchema(String schemaName) Get the schema if it exists, or null if not. Parameters: schemaName - the name of the schema Returns: the schema or null
Setting | findSetting(String name) Get the setting if it exists, or null if not.
Setting | findSetting(String name) Get the setting if it exists, or null if not. Parameters: name - the name of the setting Returns: the setting or null
User | findUser(String name) Get the user if it exists, or null if not.
User | findUser(String name) Get the user if it exists, or null if not. Parameters: name - the name of the user Returns: the user or null
void | flush() Flush all pending changes to the transaction log.
void | flush() Flush all pending changes to the transaction log.
ArrayList | getAllAggregates()
ArrayList | getAllAggregates()
ArrayList | getAllComments()
ArrayList | getAllComments()
ArrayList | getAllDomains()
ArrayList | getAllDomains()
ArrayList | getAllRights()
ArrayList | getAllRights()
ArrayList | getAllRoles()
ArrayList | getAllRoles()
ArrayList | getAllSchemaObjects() Get all schema objects.
ArrayList | getAllSchemaObjects() Get all schema objects. Returns: all objects of all types
ArrayList | getAllSchemaObjects(int type) Get all schema objects of the given type.
ArrayList | getAllSchemaObjects(int type) Get all schema objects of the given type. Parameters: type - the object type Returns: all objects of that type
ArrayList | getAllSchemas()
ArrayList | getAllSchemas()
ArrayList | getAllSettings()
ArrayList | getAllSettings()
ArrayList | getAllSynonyms() Get all synonyms.
ArrayList | getAllSynonyms() Get all synonyms. Returns: all objects of that type
ArrayList | getAllTablesAndViews(boolean includeMeta) Get all tables and views.
ArrayList | getAllTablesAndViews(boolean includeMeta) Get all tables and views. Parameters: includeMeta - whether to force including the meta data tables (if true, metadata tables are always included; if false, metadata tables are only included if they are already initialized) Returns: all objects of that type
ArrayList | getAllUsers()
ArrayList | getAllUsers()
int | getAllowLiterals()
int | getAllowLiterals()
Authenticator | getAuthenticator() get authenticator for database users
Authenticator | getAuthenticator() get authenticator for database users Returns: authenticator set for database
Throwable | getBackgroundException()
Throwable | getBackgroundException()
String | getCacheType()
String | getCacheType()
String | getCluster()
String | getCluster()
CompareMode | getCompareMode()
CompareMode | getCompareMode()
SourceCompiler | getCompiler()
SourceCompiler | getCompiler()
String | getDatabasePath()
String | getDatabasePath()
int | getDefaultTableType()
int | getDefaultTableType()
Table | getDependentTable(SchemaObject obj, Table except) Get the first table that depends on this object.
Table | getDependentTable(SchemaObject obj, Table except) Get the first table that depends on this object. Parameters: obj - the object to find except - the table to exclude (or null) Returns: the first dependent table, or null
Session | getExclusiveSession()
Session | getExclusiveSession()
byte[] | getFileEncryptionKey()
byte[] | getFileEncryptionKey()
Table | getFirstUserTable() Get the first user defined table, excluding the LOB_BLOCKS table that the Recover tool creates.
Table | getFirstUserTable() Get the first user defined table, excluding the LOB_BLOCKS table that the Recover tool creates. Returns: the table or null if no table is defined
boolean | getFlushOnEachCommit() Check if flush-on-each-commit is enabled.
boolean | getFlushOnEachCommit() Check if flush-on-each-commit is enabled. Returns: true if it is
boolean | getIgnoreCase()
boolean | getIgnoreCase()
ArrayList | getInDoubtTransactions() Get the list of in-doubt transactions.
ArrayList | getInDoubtTransactions() Get the list of in-doubt transactions. Returns: the list
JavaObjectSerializer | getJavaObjectSerializer()
JavaObjectSerializer | getJavaObjectSerializer()
TableLinkConnection | getLinkConnection(String driver, String url, String user, String password) Open a new connection or get an existing connection to another database.
TableLinkConnection | getLinkConnection(String driver, String url, String user, String password) Open a new connection or get an existing connection to another database. Parameters: driver - the database driver or null url - the database URL user - the user name password - the password Returns: the connection
String | getLobCompressionAlgorithm(int type)
String | getLobCompressionAlgorithm(int type)
JdbcConnection | getLobConnectionForInit()
JdbcConnection | getLobConnectionForInit()
JdbcConnection | getLobConnectionForRegularUse()
JdbcConnection | getLobConnectionForRegularUse()
SmallLRUCache | getLobFileListCache()
SmallLRUCache | getLobFileListCache()
Session | getLobSession()
Session | getLobSession()
LobStorageInterface | getLobStorage()
LobStorageInterface | getLobStorage()
Object | getLobSyncObject()
Object | getLobSyncObject()
int | getLockMode()
int | getLockMode()
int | getLockTimeout()
int | getLockTimeout()
int | getLogMode()
int | getLogMode()
Schema | getMainSchema() Returns main schema (usually PUBLIC).
Schema | getMainSchema() Returns main schema (usually PUBLIC). Returns: main schema (usually PUBLIC)
int | getMaxLengthInplaceLob()
int | getMaxLengthInplaceLob()
int | getMaxMemoryRows()
int | getMaxMemoryRows()
int | getMaxMemoryUndo()
int | getMaxMemoryUndo()
int | getMaxOperationMemory()
int | getMaxOperationMemory()
Mode | getMode()
Mode | getMode()
long | getModificationDataId()
long | getModificationDataId()
long | getModificationMetaId()
long | getModificationMetaId()
String | getName()
String | getName()
long | getNextModificationDataId()
long | getNextModificationDataId()
long | getNextModificationMetaId()
long | getNextModificationMetaId()
boolean | getOptimizeReuseResults()
boolean | getOptimizeReuseResults()
int | getPageSize()
int | getPageSize()
PageStore | getPageStore()
PageStore | getPageStore()
int | getPowerOffCount()
int | getPowerOffCount()
Role | getPublicRole()
Role | getPublicRole()
boolean | getQueryStatistics()
boolean | getQueryStatistics()
QueryStatisticsData | getQueryStatisticsData()
QueryStatisticsData | getQueryStatisticsData()
boolean | getReferentialIntegrity()
boolean | getReferentialIntegrity()
LocalResultFactory | getResultFactory()
LocalResultFactory | getResultFactory()
int | getRetentionTime()
int | getRetentionTime()
RowFactory | getRowFactory()
RowFactory | getRowFactory()
Schema | getSchema(String schemaName) Get the schema.
Schema | getSchema(String schemaName) Get the schema. If the schema does not exist, an exception is thrown. Parameters: schemaName - the name of the schema Returns: the schema Throws: DbException - no schema with that name exists
int | getSessionCount()
int | getSessionCount()
Session[] | getSessions(boolean includingSystemSession) Get all sessions that are currently connected to the database.
Session[] | getSessions(boolean includingSystemSession) Get all sessions that are currently connected to the database. Parameters: includingSystemSession - if the system session should also be included Returns: the list of sessions
DbSettings | getSettings()
DbSettings | getSettings()
String | getShortName()
String | getShortName()
MVTableEngine.Store | getStore()
MVTableEngine.Store | getStore()
Session | getSystemSession()
Session | getSystemSession()
TableEngine | getTableEngine(String tableEngine) Get the table engine class, loading it if needed.
TableEngine | getTableEngine(String tableEngine) Get the table engine class, loading it if needed. Parameters: tableEngine - the table engine name Returns: the class
ArrayList | getTableOrViewByName(String name) Get the tables with the given name, if any.
ArrayList | getTableOrViewByName(String name) Get the tables with the given name, if any. Parameters: name - the table name Returns: the list
TempFileDeleter | getTempFileDeleter()
TempFileDeleter | getTempFileDeleter()
String | getTempTableName(String baseName, Session session) Get a unique temporary table name.
String | getTempTableName(String baseName, Session session) Get a unique temporary table name. Parameters: baseName - the prefix of the returned name session - the session Returns: a unique name
Trace | getTrace(int moduleId) Get the trace object for the given module id.
Trace | getTrace(int moduleId) Get the trace object for the given module id. Parameters: moduleId - the module id Returns: the trace object
TraceSystem | getTraceSystem()
TraceSystem | getTraceSystem()
User | getUser(String name) Get user with the given name.
User | getUser(String name) Get user with the given name. This method throws an exception if the user does not exist. Parameters: name - the user name Returns: the user Throws: DbException - if the user does not exist
boolean | isAllowBuiltinAliasOverride()
boolean | isAllowBuiltinAliasOverride()
boolean | isClosing() Check if the database is in the process of closing.
boolean | isClosing() Check if the database is in the process of closing. Returns: true if the database is closing
boolean | isFileLockSerialized()
boolean | isFileLockSerialized()
boolean | isMVStore() Check if MVStore backend is used for this database.
boolean | isMVStore() Check if MVStore backend is used for this database. Returns: {@code true} for MVStore, {@code false} for PageStore
boolean | isMultiThreaded()
boolean | isMultiThreaded()
boolean | isPersistent() Check if this database is disk-based.
boolean | isPersistent() Check if this database is disk-based. Returns: true if it is disk-based, false if it is in-memory only.
boolean | isReadOnly()
boolean | isReadOnly()
boolean | isReconnectNeeded() Check if the contents of the database was changed and therefore it is required to re-connect.
boolean | isReconnectNeeded() Check if the contents of the database was changed and therefore it is required to re-connect. This method waits until pending changes are completed. If a pending change takes too long (more than 2 seconds), the pending change is broken (removed from the properties file). Returns: true if reconnecting is required
boolean | isStarting() Check if the database is currently opening.
boolean | isStarting() Check if the database is currently opening. This is true until all stored SQL statements have been executed. Returns: true if the database is still starting
boolean | isSysTableLocked() Checks if the system table (containing the catalog) is locked.
boolean | isSysTableLocked() Checks if the system table (containing the catalog) is locked. Returns: true if it is currently locked
boolean | isSysTableLockedBy(Session session) Checks if the system table (containing the catalog) is locked by the given session.
boolean | isSysTableLockedBy(Session session) Checks if the system table (containing the catalog) is locked by the given session. Parameters: session - the session Returns: true if it is currently locked
boolean | lockMeta(Session session) Lock the metadata table for updates.
boolean | lockMeta(Session session) Lock the metadata table for updates. Parameters: session - the session Returns: whether it was already locked before by this session
ConcurrentHashMap | newConcurrentStringMap() Create a new hash map.
ConcurrentHashMap | newConcurrentStringMap() Create a new hash map. Depending on the configuration, the key is case sensitive or case insensitive. Returns: the hash map
HashMap | newStringMap() Create a new hash map.
HashMap | newStringMap() Create a new hash map. Depending on the configuration, the key is case sensitive or case insensitive. Returns: the hash map
FileStore | openFile(String name, String openMode, boolean mustExist)
FileStore | openFile(String name, String openMode, boolean mustExist)
int | readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length)
int | readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length)
void | removeDatabaseObject(Session session, DbObject obj) Remove the object from the database.
void | removeDatabaseObject(Session session, DbObject obj) Remove the object from the database. Parameters: session - the session obj - the object to remove
void | removeMeta(Session session, int id) Remove the given object from the meta data.
void | removeMeta(Session session, int id) Remove the given object from the meta data. Parameters: session - the session id - the id of the object to remove
void | removeSchemaObject(Session session, SchemaObject obj) Remove an object from the system table.
void | removeSchemaObject(Session session, SchemaObject obj) Remove an object from the system table. Parameters: session - the session obj - the object to be removed
void | removeSession(Session session) Remove a session.
void | removeSession(Session session) Remove a session. This method is called after the user has disconnected. Parameters: session - the session
void | renameDatabaseObject(Session session, DbObject obj, String newName) Rename a database object.
void | renameDatabaseObject(Session session, DbObject obj, String newName) Rename a database object. Parameters: session - the session obj - the object newName - the new name
void | renameSchemaObject(Session session, SchemaObject obj, String newName) Rename a schema object.
void | renameSchemaObject(Session session, SchemaObject obj, String newName) Rename a schema object. Parameters: session - the session obj - the object newName - the new name
void | setAllowBuiltinAliasOverride(boolean b)
void | setAllowBuiltinAliasOverride(boolean b)
void | setAllowLiterals(int value)
void | setAllowLiterals(int value)
void | setAuthenticator(Authenticator authenticator) Set current database authenticator
void | setAuthenticator(Authenticator authenticator) Set current database authenticator Parameters: authenticator - = authenticator to set, null to revert to the Internal authenticator
void | setBackgroundException(DbException e)
void | setBackgroundException(DbException e)
void | setCacheSize(int kb)
void | setCacheSize(int kb)
void | setCloseDelay(int value)
void | setCloseDelay(int value)
void | setCluster(String cluster)
void | setCluster(String cluster)
void | setCompactMode(int compactMode)
void | setCompactMode(int compactMode)
void | setCompareMode(CompareMode compareMode)
void | setCompareMode(CompareMode compareMode)
void | setDefaultTableType(int defaultTableType)
void | setDefaultTableType(int defaultTableType)
void | setDeleteFilesOnDisconnect(boolean b)
void | setDeleteFilesOnDisconnect(boolean b)
void | setEventListener(DatabaseEventListener eventListener)
void | setEventListener(DatabaseEventListener eventListener)
void | setEventListenerClass(String className)
void | setEventListenerClass(String className)
void | setExclusiveSession(Session session, boolean closeOthers) Set the session that can exclusively access the database.
void | setExclusiveSession(Session session, boolean closeOthers) Set the session that can exclusively access the database. Parameters: session - the session closeOthers - whether other sessions are closed
void | setIgnoreCase(boolean b)
void | setIgnoreCase(boolean b)
void | setJavaObjectSerializerName(String serializerName)
void | setJavaObjectSerializerName(String serializerName)
void | setLobCompressionAlgorithm(String stringValue)
void | setLobCompressionAlgorithm(String stringValue)
void | setLockMode(int lockMode)
void | setLockMode(int lockMode)
void | setLogMode(int log)
void | setLogMode(int log)
void | setMasterUser(User user)
void | setMasterUser(User user)
void | setMaxLengthInplaceLob(int value)
void | setMaxLengthInplaceLob(int value)
void | setMaxLogSize(long value)
void | setMaxLogSize(long value)
void | setMaxMemoryRows(int value)
void | setMaxMemoryRows(int value)
void | setMaxMemoryUndo(int value)
void | setMaxMemoryUndo(int value)
void | setMaxOperationMemory(int maxOperationMemory)
void | setMaxOperationMemory(int maxOperationMemory)
void | setMode(Mode mode)
void | setMode(Mode mode)
void | setMultiThreaded(boolean multiThreaded)
void | setMultiThreaded(boolean multiThreaded)
void | setOptimizeReuseResults(boolean b)
void | setOptimizeReuseResults(boolean b)
void | setPowerOffCount(int count)
void | setPowerOffCount(int count)
void | setProgress(int state, String name, int x, int max) Set the progress of a long running operation.
void | setProgress(int state, String name, int x, int max) Set the progress of a long running operation. This method calls the {@link DatabaseEventListener} if one is registered. Parameters: state - the {@link DatabaseEventListener} state name - the object name x - the current position max - the highest value
void | setQueryStatistics(boolean b)
void | setQueryStatistics(boolean b)
void | setQueryStatisticsMaxEntries(int n)
void | setQueryStatisticsMaxEntries(int n)
void | setReadOnly(boolean readOnly) Switch the database to read-only mode.
void | setReadOnly(boolean readOnly) Switch the database to read-only mode. Parameters: readOnly - the new value
void | setReferentialIntegrity(boolean b)
void | setReferentialIntegrity(boolean b)
void | setResultFactory(LocalResultFactory resultFactory)
void | setResultFactory(LocalResultFactory resultFactory)
void | setRetentionTime(int value)
void | setRetentionTime(int value)
void | setRowFactory(RowFactory rowFactory)
void | setRowFactory(RowFactory rowFactory)
void | setStore(MVTableEngine.Store store)
void | setStore(MVTableEngine.Store store)
void | setWriteDelay(int value)
void | setWriteDelay(int value)
void | shutdownImmediately() Immediately close the database.
void | shutdownImmediately() Immediately close the database.
void | sync() Synchronize the files with the file system.
void | sync() Synchronize the files with the file system. This method is called when executing the SQL statement CHECKPOINT SYNC.
String | sysIdentifier(String upperName) Returns identifier in upper or lower case depending on database settings.
String | sysIdentifier(String upperName) Returns identifier in upper or lower case depending on database settings. Parameters: upperName - identifier in the upper case Returns: identifier in upper or lower case
String | toString()
String | toString()
void | unlockMeta(Session session) Unlock the metadata table.
void | unlockMeta(Session session) Unlock the metadata table. Parameters: session - the session
void | unlockMetaDebug(Session session) This method doesn't actually unlock the metadata table, all it does it reset the debugging flags.
void | unlockMetaDebug(Session session) This method doesn't actually unlock the metadata table, all it does it reset the debugging flags. Parameters: session - the session
void | updateMeta(Session session, DbObject obj) Update an object in the system table.
void | updateMeta(Session session, DbObject obj) Update an object in the system table. Parameters: session - the session obj - the database object
void | verifyMetaLocked(Session session) Verify the meta table is locked.
void | verifyMetaLocked(Session session) Verify the meta table is locked. Parameters: session - the session