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(SessionLocal session, DbObject obj)
Add an object to the database.
void addDatabaseObject(SessionLocal session, DbObject obj)
Add an object to the database.
Parameters:
session - the session
obj - the object to add
void addSchemaObject(SessionLocal session, SchemaObject obj)
Add a schema object to the database.
void addSchemaObject(SessionLocal session, SchemaObject obj)
Add a schema object to the database.
Parameters:
session - the session
obj - the object to add
int allocateObjectId()
Allocate a new object id.
int allocateObjectId()
Allocate a new object id.
Returns:
the id
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.
TimeZoneProvider currentTimeZone()
TimeZoneProvider currentTimeZone()
ValueTimestampTimeZone currentTimestamp()
ValueTimestampTimeZone currentTimestamp()
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
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
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
RightOwner findUserOrRole(String name)
Get the user or role if it exists, or
RightOwner findUserOrRole(String name)
Get the user or role if it exists, or {@code null} if not.
Parameters:
name - the name of the user or role
Returns:
the user, the role, or {@code null}
void flush()
Flush all pending changes to the transaction log.
void flush()
Flush all pending changes to the transaction log.
ArrayList getAllComments()
ArrayList getAllComments()
ArrayList getAllRights()
ArrayList getAllRights()
Collection getAllSchemas()
Collection getAllSchemas()
Collection getAllSchemasNoMeta()
Collection getAllSchemasNoMeta()
Collection getAllSettings()
Collection getAllSettings()
ArrayList getAllSynonyms()
Get all synonyms.
ArrayList getAllSynonyms()
Get all synonyms.
Returns:
all objects of that type
ArrayList getAllTablesAndViews()
Get all tables and views.
ArrayList getAllTablesAndViews()
Get all tables and views. Meta data tables may be excluded.
Returns:
all objects of that type
Collection getAllUsersAndRoles()
Collection getAllUsersAndRoles()
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()
DefaultNullOrdering getDefaultNullOrdering()
DefaultNullOrdering getDefaultNullOrdering()
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
SessionLocal getExclusiveSession()
SessionLocal 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 getIgnoreCase()
boolean getIgnoreCase()
boolean getIgnoreCatalogs()
boolean getIgnoreCatalogs()
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
SmallLRUCache getLobFileListCache()
SmallLRUCache getLobFileListCache()
SessionLocal getLobSession()
SessionLocal getLobSession()
LobStorageInterface getLobStorage()
LobStorageInterface getLobStorage()
Object getLobSyncObject()
Object getLobSyncObject()
int getLockMode()
int getLockMode()
int getLockTimeout()
int getLockTimeout()
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 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()
long getNextRemoteSettingsId()
long getNextRemoteSettingsId()
boolean getOptimizeReuseResults()
boolean getOptimizeReuseResults()
int getPageSize()
int getPageSize()
int getPowerOffCount()
int getPowerOffCount()
Role getPublicRole()
Role getPublicRole()
boolean getQueryStatistics()
boolean getQueryStatistics()
QueryStatisticsData getQueryStatisticsData()
QueryStatisticsData getQueryStatisticsData()
boolean getReferentialIntegrity()
boolean getReferentialIntegrity()
long getRemoteSettingsId()
long getRemoteSettingsId()
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()
SessionLocal[] getSessions(boolean includingSystemSession)
Get all sessions that are currently connected to the database.
SessionLocal[] 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()
Store getStore()
Store getStore()
SessionLocal getSystemSession()
SessionLocal getSystemSession()
User getSystemUser()
Returns system user.
User getSystemUser()
Returns system user.
Returns:
system user
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
TempFileDeleter getTempFileDeleter()
TempFileDeleter getTempFileDeleter()
String getTempTableName(String baseName, SessionLocal session)
Get a unique temporary table name.
String getTempTableName(String baseName, SessionLocal 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 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 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(SessionLocal session)
Checks if the system table (containing the catalog) is locked by the given session.
boolean isSysTableLockedBy(SessionLocal 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(SessionLocal session)
Lock the metadata table for updates.
boolean lockMeta(SessionLocal 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
HashMap newStringMap(int initialCapacity)
Create a new hash map.
HashMap newStringMap(int initialCapacity)
Create a new hash map. Depending on the configuration, the key is case sensitive or case insensitive.
Parameters:
initialCapacity - the initial capacity
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 releaseDatabaseObjectIds(BitSet idsToRelease)
Mark some database ids as unused.
void releaseDatabaseObjectIds(BitSet idsToRelease)
Mark some database ids as unused.
Parameters:
idsToRelease - the ids to release
void removeDatabaseObject(SessionLocal session, DbObject obj)
Remove the object from the database.
void removeDatabaseObject(SessionLocal session, DbObject obj)
Remove the object from the database.
Parameters:
session - the session
obj - the object to remove
void removeMeta(SessionLocal session, int id)
Remove the given object from the meta data.
void removeMeta(SessionLocal 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(SessionLocal session, SchemaObject obj)
Remove an object from the system table.
void removeSchemaObject(SessionLocal session, SchemaObject obj)
Remove an object from the system table.
Parameters:
session - the session
obj - the object to be removed
void removeSession(SessionLocal session)
Remove a session.
void removeSession(SessionLocal session)
Remove a session. This method is called after the user has disconnected.
Parameters:
session - the session
void renameDatabaseObject(SessionLocal session, DbObject obj, String newName)
Rename a database object.
void renameDatabaseObject(SessionLocal session, DbObject obj, String newName)
Rename a database object.
Parameters:
session - the session
obj - the object
newName - the new name
void renameSchemaObject(SessionLocal session, SchemaObject obj, String newName)
Rename a schema object.
void renameSchemaObject(SessionLocal 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 setDefaultNullOrdering(DefaultNullOrdering defaultNullOrdering)
void setDefaultNullOrdering(DefaultNullOrdering defaultNullOrdering)
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)
boolean setExclusiveSession(SessionLocal session, boolean closeOthers)
Set the session that can exclusively access the database.
boolean setExclusiveSession(SessionLocal session, boolean closeOthers)
Set the session that can exclusively access the database.
Parameters:
session - the session
closeOthers - whether other sessions are closed
Returns:
true if success or if database is in exclusive mode set by this session already, false otherwise
void setIgnoreCase(boolean b)
void setIgnoreCase(boolean b)
void setIgnoreCatalogs(boolean b)
void setIgnoreCatalogs(boolean b)
void setJavaObjectSerializerName(String serializerName)
void setJavaObjectSerializerName(String serializerName)
void setLockMode(int lockMode)
void setLockMode(int lockMode)
void setMasterUser(User user)
void setMasterUser(User user)
void setMaxLengthInplaceLob(int value)
void setMaxLengthInplaceLob(int value)
void setMaxMemoryRows(int value)
void setMaxMemoryRows(int value)
void setMaxOperationMemory(int maxOperationMemory)
void setMaxOperationMemory(int maxOperationMemory)
void setMode(Mode mode)
void setMode(Mode mode)
void setOptimizeReuseResults(boolean b)
void setOptimizeReuseResults(boolean b)
void setPowerOffCount(int count)
void setPowerOffCount(int count)
void setProgress(int state, String name, long x, long max)
Set the progress of a long running operation.
void setProgress(int state, String name, long x, long 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 or 0 if unknown
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 setRetentionTime(int value)
void setRetentionTime(int value)
void setRowFactory(RowFactory rowFactory)
void setRowFactory(RowFactory rowFactory)
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(SessionLocal session)
Unlock the metadata table.
void unlockMeta(SessionLocal session)
Unlock the metadata table.
Parameters:
session - the session
boolean unsetExclusiveSession(SessionLocal session)
Stop exclusive access the database by provided session.
boolean unsetExclusiveSession(SessionLocal session)
Stop exclusive access the database by provided session.
Parameters:
session - the session
Returns:
true if success or if database is in non-exclusive mode already, false otherwise
void updateMeta(SessionLocal session, DbObject obj)
Update an object in the system table.
void updateMeta(SessionLocal session, DbObject obj)
Update an object in the system table.
Parameters:
session - the session
obj - the database object
void verifyMetaLocked(SessionLocal session)
Verify the meta table is locked.
void verifyMetaLocked(SessionLocal session)
Verify the meta table is locked.
Parameters:
session - the session
boolean zeroBasedEnums()
boolean zeroBasedEnums()