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 not 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 compareTypeSave(Value a, Value b)
Compare two values with the current comparison mode.
int compareTypeSave(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
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
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
UserDataType findUserDataType(String name)
Get the user defined data type if it exists, or null if not.
UserDataType findUserDataType(String name)
Get the user defined data type if it exists, or null if not.
Parameters:
name - the name of the user defined data type
Returns:
the user defined data type 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 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 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 getAllUserDataTypes()
ArrayList getAllUserDataTypes()
ArrayList getAllUsers()
ArrayList getAllUsers()
int getAllowLiterals()
int getAllowLiterals()
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.
Table getFirstUserTable()
Get the first user defined table.
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 getLogMode()
int getLogMode()
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()
MVTableEngine.Store getMvStore()
MVTableEngine.Store getMvStore()
String getName()
String getName()
long getNextModificationDataId()
long getNextModificationDataId()
long getNextModificationMetaId()
long getNextModificationMetaId()
boolean getOptimizeReuseResults()
boolean getOptimizeReuseResults()
PageStore getPageStore()
PageStore getPageStore()
int getPowerOffCount()
int getPowerOffCount()
Role getPublicRole()
Role getPublicRole()
boolean getQueryStatistics()
boolean getQueryStatistics()
QueryStatisticsData getQueryStatisticsData()
QueryStatisticsData getQueryStatisticsData()
boolean getReferentialIntegrity()
boolean getReferentialIntegrity()
int getRetentionTime()
int getRetentionTime()
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()
Session getSystemSession()
Session getSystemSession()
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(String module)
Get the trace object for the given module.
Trace getTrace(String module)
Get the trace object for the given module.
Parameters:
module - the module name
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 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 isMultiThreaded()
boolean isMultiThreaded()
boolean isMultiVersion()
Check if multi version concurrency is enabled for this database.
boolean isMultiVersion()
Check if multi version concurrency is enabled for this database.
Returns:
true if it is enabled
boolean isPersistent()
Check if this database disk-based.
boolean isPersistent()
Check if this database disk-based.
Returns:
true if it is disk-based, false it 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 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
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 setAllowLiterals(int value)
void setAllowLiterals(int value)
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 setMultiVersion(boolean multiVersion)
void setMultiVersion(boolean multiVersion)
void setMvStore(MVTableEngine.Store mvStore)
void setMvStore(MVTableEngine.Store mvStore)
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 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 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 toString()
String toString()
void update(Session session, DbObject obj)
Update an object in the system table.
void update(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