## org.h2.engine
Class Database

    java.lang.Object
      org.h2.engine.Database

All Implemented Interfaces:
  DataHandler

    public class Database

extends java.lang.Object
implements DataHandler

There is one database object per open database. The format of the meta data table is: id int, headPos int (for indexes), objectType int, sql varchar

Since:
  2004-04-15 22:49

Constructor Summary
`Database(java.lang.String name, ConnectionInfo ci, java.lang.String cipher)`

Method Summary
`void` `addDatabaseObject(Session session, DbObject obj)` Add an object to the database.
`void` `addSchemaObject(Session session, SchemaObject obj)` Add a schema object to the database.
`void` `afterWriting()` This method is called after updates are finished.
`int` `allocateObjectId(boolean needFresh, boolean dataFile)` Get the next object id.
`boolean` `areEqual(Value a, Value b)` Check if two values are equal with the current comparison mode.
`boolean` `beforeWriting()` This method is called before writing to the log file.
`void` `checkpoint()` Flush all changes and open a new log file.
`void` `checkpointIfRequired()` Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed.
`void` `checkPowerOff()` Check if the simulated power failure occurred.
`void` `checkWritingAllowed()` Check if writing is allowed.
`int` `compare(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.
`Session` `createSession(User user)` Create a session for the given user.
`java.lang.String` `createTempFile()` Create a temporary file and return the file name.
`void` `deleteLogFileLater(java.lang.String fileName)` Delete an unused log file.
`void` `exceptionThrown(java.sql.SQLException e, java.lang.String sql)` This method is called after an exception occurred, to inform the database event listener (if one is set).
`static boolean` `exists(java.lang.String name)` Check if a database with the given name exists.
`UserAggregate` `findAggregate(java.lang.String name)` Get the user defined aggregate function if it exists, or null if not.
`Comment` `findComment(DbObject object)` Get the comment for the given database object if one exists, or null if not.
`FunctionAlias` `findFunctionAlias(java.lang.String name)` Get the user defined function if it exists, or null if not.
`Role` `findRole(java.lang.String roleName)` Get the role if it exists, or null if not.
`Schema` `findSchema(java.lang.String schemaName)` Get the schema if it exists, or null if not.
`Setting` `findSetting(java.lang.String name)` Get the setting if it exists, or null if not.
`User` `findUser(java.lang.String name)` Get the user if it exists, or null if not.
`UserDataType` `findUserDataType(java.lang.String name)` Get the user defined data type if it exists, or null if not.
`void` `flushIndexes(long maxLastChange)` Flush the indexes that were last changed prior to some time.
`void` `freeUpDiskSpace()` Free up disk space if possible.
`ObjectArray<UserAggregate>` `getAllAggregates()`
`ObjectArray<Comment>` `getAllComments()`
`ObjectArray<FunctionAlias>` `getAllFunctionAliases()`
`int` `getAllowLiterals()`
`ObjectArray<Right>` `getAllRights()`
`ObjectArray<Role>` `getAllRoles()`
`ObjectArray<SchemaObject>` `getAllSchemaObjects(int type)` Get all schema objects of the given type.
`ObjectArray<Schema>` `getAllSchemas()`
`ObjectArray<Setting>` `getAllSettings()`
`ObjectArray<Storage>` `getAllStorages()`
`ObjectArray<Table>` `getAllTablesAndViews()` Get all tables and views.
`ObjectArray<UserDataType>` `getAllUserDataTypes()`
`ObjectArray<User>` `getAllUsers()`
`java.lang.String` `getCacheType()`
`int` `getChecksum(byte[] data, int start, int end)` Calculate the checksum for the byte array.
`java.lang.String` `getCluster()`
`CompareMode` `getCompareMode()`
`SourceCompiler` `getCompiler()`
`java.lang.String` `getDatabasePath()` Get the database path.
`DiskFile` `getDataFile()`
`DataPage` `getDataPage()`
`Table` `getDependentTable(SchemaObject obj, Table except)` Get the first table that depends on this object.
`Session` `getExclusiveSession()`
`Table` `getFirstUserTable()` Get the first user defined table.
`boolean` `getIgnoreCase()`
`DiskFile` `getIndexFile()`
`TableLinkConnection` `getLinkConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)` Open a new connection or get an existing connection to another database.
`java.lang.String` `getLobCompressionAlgorithm(int type)` Get the compression algorithm used for large objects.
`SmallLRUCache<java.lang.String,java.lang.String[]>` `getLobFileListCache()` Get the lob file list cache if it is used.
`boolean` `getLobFilesInDirectories()` Checks if the lob files stored in directories.
`java.lang.Object` `getLobSyncObject()` Get the synchronization object for lob operations.
`int` `getLockMode()`
`LogSystem` `getLog()`
`boolean` `getLogIndexChanges()`
`Schema` `getMainSchema()`
`int` `getMaxLengthInplaceLob()` Get the maximum length of a in-place large object
`int` `getMaxMemoryRows()`
`int` `getMaxMemoryUndo()`
`int` `getMaxOperationMemory()`
`Mode` `getMode()`
`long` `getModificationDataId()`
`long` `getModificationMetaId()`
`java.lang.String` `getName()`
`long` `getNextModificationDataId()`
`long` `getNextModificationMetaId()`
`boolean` `getOptimizeReuseResults()`
`PageStore` `getPageStore()`
`int` `getPowerOffCount()`
`Role` `getPublicRole()`
`boolean` `getRecovery()`
`boolean` `getReferentialIntegrity()`
`Schema` `getSchema(java.lang.String schemaName)` Get the schema.
`int` `getSessionCount()`
`Session[]` `getSessions(boolean includingSystemSession)` Get all sessions that are currently connected to the database.
`java.lang.String` `getShortName()`
`Storage` `getStorage(int id, DiskFile file)` Get the storage object for the given file.
`Storage` `getStorage(RecordReader reader, int id, boolean dataFile)` Get or create the specified storage object.
`Session` `getSystemSession()`
`TempFileDeleter` `getTempFileDeleter()` Get the temp file deleter mechanism.
`java.lang.String` `getTempTableName(Session session)` Get a unique temporary table name.
`Trace` `getTrace()` Get the trace writer.
`Trace` `getTrace(java.lang.String module)` Get the trace object for the given module.
`TraceSystem` `getTraceSystem()`
`User` `getUser(java.lang.String name)` Get user with the given name.
`void` `handleInvalidChecksum()` Called when the checksum was invalid.
`void` `invalidateIndexSummary()` Called when the summary of the index in the log file has become invalid.
`boolean` `isClosing()` Check if the database is in the process of closing.
`boolean` `isFileLockSerialized()`
`boolean` `isIndexSummaryValid()`
`boolean` `isMultiThreaded()`
`boolean` `isMultiVersion()` Check if multi version concurrency is enabled for this database.
`boolean` `isPageStoreEnabled()`
`boolean` `isPersistent()` Check if this database disk-based.
`boolean` `isReadOnly()`
`boolean` `isReconnectNeeded()` Check if the contents of the database was changed and therefore it is required to re-connect.
`boolean` `isStarting()` Check if the database is currently opening.
`boolean` `isSysTableLocked()` Checks if the system table (containing the catalog) is locked.
`void` `notifyFileSize(long length)` Called when the size if the data or index file has been changed.
`void` `opened()` Called after the database has been opened and initialized.
`FileStore` `openFile(java.lang.String name, java.lang.String openMode, boolean mustExist)` Open a file at the given location.
`void` `removeDatabaseObject(Session session, DbObject obj)` Remove the object from the database.
`void` `removeMeta(Session session, int id)` Remove the given object from the meta data.
`void` `removeSchemaObject(Session session, SchemaObject obj)` Remove an object from the system table.
`void` `removeSession(Session session)` Remove a session.
`void` `removeStorage(int id, DiskFile file)` Remove the storage object from the file.
`void` `renameDatabaseObject(Session session, DbObject obj, java.lang.String newName)` Rename a database object.
`void` `renameSchemaObject(Session session, SchemaObject obj, java.lang.String newName)` Rename a schema object.
`void` `setAllowLiterals(int value)`
`void` `setCacheSize(int kb)`
`void` `setCloseDelay(int value)`
`void` `setCluster(java.lang.String cluster)`
`void` `setCompactFully(boolean compactFully)`
`void` `setCompareMode(CompareMode compareMode)`
`void` `setDeleteFilesOnDisconnect(boolean b)`
`void` `setEventListener(DatabaseEventListener eventListener)`
`void` `setEventListenerClass(java.lang.String className)`
`void` `setExclusiveSession(Session session)`
`void` `setIgnoreCase(boolean b)`
`static void` `setInitialPowerOffCount(int count)`
`void` `setLobCompressionAlgorithm(java.lang.String stringValue)`
`void` `setLockMode(int lockMode)`
`void` `setLog(int level)`
`void` `setMasterUser(User user)`
`void` `setMaxLengthInplaceLob(int value)`
`void` `setMaxLogSize(long value)`
`void` `setMaxMemoryRows(int value)`
`void` `setMaxMemoryUndo(int value)`
`void` `setMaxOperationMemory(int maxOperationMemory)`
`void` `setMode(Mode mode)`
`void` `setMultiThreaded(boolean multiThreaded)`
`void` `setOptimizeReuseResults(boolean b)`
`void` `setPowerOffCount(int count)`
`void` `setProgress(int state, java.lang.String name, int x, int max)` Set the progress of a long running operation.
`void` `setReadOnly(boolean readOnly)` Switch the database to read-only mode.
`void` `setReferentialIntegrity(boolean b)`
`void` `setWriteDelay(int value)`
`void` `shutdownImmediately()` Immediately close the database.
`void` `sync()` Synchronize the files with the file system.
`java.lang.String` `toString()`
`void` `update(Session session, DbObject obj)` Update an object in the system table.
`boolean` `validateFilePasswordHash(java.lang.String testCipher, byte[] testHash)` Check if the file password hash is correct.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Database

    public Database(java.lang.String name,
                    ConnectionInfo ci,
                    java.lang.String cipher)
             throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

Method Detail

### setInitialPowerOffCount

    public static void setInitialPowerOffCount(int count)

### setPowerOffCount

    public void setPowerOffCount(int count)

### areEqual

    public boolean areEqual(Value a,
                            Value b)
                     throws java.sql.SQLException

  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
  Throws:
    `java.sql.SQLException`

### compare

    public int compare(Value a,
                       Value b)
                throws java.sql.SQLException

  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
  Throws:
    `java.sql.SQLException`

### compareTypeSave

    public int compareTypeSave(Value a,
                               Value b)
                        throws java.sql.SQLException

  Compare two values with the current comparison mode. The values must be of the same type.

  Specified by:
    `compareTypeSave` in interface `DataHandler`
  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
  Throws:
    `java.sql.SQLException`

### getModificationDataId

    public long getModificationDataId()

### getNextModificationDataId

    public long getNextModificationDataId()

### getModificationMetaId

    public long getModificationMetaId()

### getNextModificationMetaId

    public long getNextModificationMetaId()

### getPowerOffCount

    public int getPowerOffCount()

### checkPowerOff

    public void checkPowerOff()
                       throws java.sql.SQLException

  Description copied from interface: `DataHandler`
  Check if the simulated power failure occurred. This call will decrement the countdown.

  Specified by:
    `checkPowerOff` in interface `DataHandler`
  Throws:
    `java.sql.SQLException` - if the simulated power failure occurred

### exists

    public static boolean exists(java.lang.String name)

  Check if a database with the given name exists.

  Parameters:
    `name` - the name of the database (including path)
  Returns:
    true if one exists

### getTrace

    public Trace getTrace(java.lang.String module)

  Get the trace object for the given module.

  Parameters:
    `module` - the module name
  Returns:
    the trace object

### openFile

    public FileStore openFile(java.lang.String name,
                              java.lang.String openMode,
                              boolean mustExist)
                       throws java.sql.SQLException

  Description copied from interface: `DataHandler`
  Open a file at the given location.

  Specified by:
    `openFile` in interface `DataHandler`
  Parameters:
    `name` - the file name
    `openMode` - the mode
    `mustExist` - whether the file must already exist
  Returns:
    the file
  Throws:
    `java.sql.SQLException`

### validateFilePasswordHash

    public boolean validateFilePasswordHash(java.lang.String testCipher,
                                            byte[] testHash)

  Check if the file password hash is correct.

  Parameters:
    `testCipher` - the cipher algorithm
    `testHash` - the hash code
  Returns:
    true if the cipher algorithm and the password match

### getDataPage

    public DataPage getDataPage()

### getMainSchema

    public Schema getMainSchema()

### removeStorage

    public void removeStorage(int id,
                              DiskFile file)

  Remove the storage object from the file.

  Parameters:
    `id` - the storage id
    `file` - the file

### getStorage

    public Storage getStorage(int id,
                              DiskFile file)

  Get the storage object for the given file. An new object is created if required.

  Parameters:
    `id` - the storage id
    `file` - the file
  Returns:
    the storage object

### removeMeta

    public void removeMeta(Session session,
                           int id)
                    throws java.sql.SQLException

  Remove the given object from the meta data.

  Parameters:
    `session` - the session
    `id` - the id of the object to remove
  Throws:
    `java.sql.SQLException`

### addSchemaObject

    public void addSchemaObject(Session session,
                                SchemaObject obj)
                         throws java.sql.SQLException

  Add a schema object to the database.

  Parameters:
    `session` - the session
    `obj` - the object to add
  Throws:
    `java.sql.SQLException`

### addDatabaseObject

    public void addDatabaseObject(Session session,
                                  DbObject obj)
                           throws java.sql.SQLException

  Add an object to the database.

  Parameters:
    `session` - the session
    `obj` - the object to add
  Throws:
    `java.sql.SQLException`

### findAggregate

    public UserAggregate findAggregate(java.lang.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

### findComment

    public 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

### findFunctionAlias

    public FunctionAlias findFunctionAlias(java.lang.String name)

  Get the user defined function if it exists, or null if not.

  Parameters:
    `name` - the name of the user defined function
  Returns:
    the function or null

### findRole

    public Role findRole(java.lang.String roleName)

  Get the role if it exists, or null if not.

  Parameters:
    `roleName` - the name of the role
  Returns:
    the role or null

### findSchema

    public Schema findSchema(java.lang.String schemaName)

  Get the schema if it exists, or null if not.

  Parameters:
    `schemaName` - the name of the schema
  Returns:
    the schema or null

### findSetting

    public Setting findSetting(java.lang.String name)

  Get the setting if it exists, or null if not.

  Parameters:
    `name` - the name of the setting
  Returns:
    the setting or null

### findUser

    public User findUser(java.lang.String name)

  Get the user if it exists, or null if not.

  Parameters:
    `name` - the name of the user
  Returns:
    the user or null

### findUserDataType

    public UserDataType findUserDataType(java.lang.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

### getUser

    public User getUser(java.lang.String name)
                 throws java.sql.SQLException

  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:
    `java.sql.SQLException` - if the user does not exist

### createSession

    public Session createSession(User user)
                          throws java.sql.SQLException

  Create a session for the given user.

  Parameters:
    `user` - the user
  Returns:
    the session
  Throws:
    `java.sql.SQLException` - if the database is in exclusive mode

### removeSession

    public void removeSession(Session session)

  Remove a session. This method is called after the user has disconnected.

  Parameters:
    `session` - the session

### allocateObjectId

    public int allocateObjectId(boolean needFresh,
                                boolean dataFile)

  Description copied from interface: `DataHandler`
  Get the next object id. This method is not required if LOB_FILES_IN_DIRECTORIES is enabled.

  Specified by:
    `allocateObjectId` in interface `DataHandler`
  Parameters:
    `needFresh` - if a fresh id is required
    `dataFile` - true if the id is for the data file
  Returns:
    the new id

### getAllAggregates

    public ObjectArray<UserAggregate> getAllAggregates()

### getAllComments

    public ObjectArray<Comment> getAllComments()

### getAllFunctionAliases

    public ObjectArray<FunctionAlias> getAllFunctionAliases()

### getAllowLiterals

    public int getAllowLiterals()

### getAllRights

    public ObjectArray<Right> getAllRights()

### getAllRoles

    public ObjectArray<Role> getAllRoles()

### getAllSchemaObjects

    public ObjectArray<SchemaObject> getAllSchemaObjects(int type)

  Get all schema objects of the given type.

  Parameters:
    `type` - the object type
  Returns:
    all objects of that type

### getAllTablesAndViews

    public ObjectArray<Table> getAllTablesAndViews()

  Get all tables and views.

  Returns:
    all objects of that type

### getAllSchemas

    public ObjectArray<Schema> getAllSchemas()

### getAllSettings

    public ObjectArray<Setting> getAllSettings()

### getAllStorages

    public ObjectArray<Storage> getAllStorages()

### getAllUserDataTypes

    public ObjectArray<UserDataType> getAllUserDataTypes()

### getAllUsers

    public ObjectArray<User> getAllUsers()

### getCacheType

    public java.lang.String getCacheType()

### getChecksum

    public int getChecksum(byte[] data,
                           int start,
                           int end)

  Description copied from interface: `DataHandler`
  Calculate the checksum for the byte array.

  Specified by:
    `getChecksum` in interface `DataHandler`
  Parameters:
    `data` - the byte array
    `start` - the starting offset
    `end` - the end offset
  Returns:
    the checksum

### getCluster

    public java.lang.String getCluster()

### getCompareMode

    public CompareMode getCompareMode()

### getDatabasePath

    public java.lang.String getDatabasePath()

  Description copied from interface: `DataHandler`
  Get the database path.

  Specified by:
    `getDatabasePath` in interface `DataHandler`
  Returns:
    the database path

### getShortName

    public java.lang.String getShortName()

### getName

    public java.lang.String getName()

### getLog

    public LogSystem getLog()

### getSessions

    public 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

### update

    public void update(Session session,
                       DbObject obj)
                throws java.sql.SQLException

  Update an object in the system table.

  Parameters:
    `session` - the session
    `obj` - the database object
  Throws:
    `java.sql.SQLException`

### renameSchemaObject

    public void renameSchemaObject(Session session,
                                   SchemaObject obj,
                                   java.lang.String newName)
                            throws java.sql.SQLException

  Rename a schema object.

  Parameters:
    `session` - the session
    `obj` - the object
    `newName` - the new name
  Throws:
    `java.sql.SQLException`

### renameDatabaseObject

    public void renameDatabaseObject(Session session,
                                     DbObject obj,
                                     java.lang.String newName)
                              throws java.sql.SQLException

  Rename a database object.

  Parameters:
    `session` - the session
    `obj` - the object
    `newName` - the new name
  Throws:
    `java.sql.SQLException`

### createTempFile

    public java.lang.String createTempFile()
                                    throws java.sql.SQLException

  Description copied from interface: `DataHandler`
  Create a temporary file and return the file name.

  Specified by:
    `createTempFile` in interface `DataHandler`
  Returns:
    the file name
  Throws:
    `java.sql.SQLException`

### getStorage

    public Storage getStorage(RecordReader reader,
                              int id,
                              boolean dataFile)

  Get or create the specified storage object.

  Parameters:
    `reader` - the record reader
    `id` - the object id
    `dataFile` - true if the data is in the data file
  Returns:
    the storage

### getSchema

    public Schema getSchema(java.lang.String schemaName)
                     throws java.sql.SQLException

  Get the schema. If the schema does not exist, an exception is thrown.

  Parameters:
    `schemaName` - the name of the schema
  Returns:
    the schema
  Throws:
    `java.sql.SQLException` - no schema with that name exists

### removeDatabaseObject

    public void removeDatabaseObject(Session session,
                                     DbObject obj)
                              throws java.sql.SQLException

  Remove the object from the database.

  Parameters:
    `session` - the session
    `obj` - the object to remove
  Throws:
    `java.sql.SQLException`

### getDependentTable

    public 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

### removeSchemaObject

    public void removeSchemaObject(Session session,
                                   SchemaObject obj)
                            throws java.sql.SQLException

  Remove an object from the system table.

  Parameters:
    `session` - the session
    `obj` - the object to be removed
  Throws:
    `java.sql.SQLException`

### isPersistent

    public boolean isPersistent()

  Check if this database disk-based.

  Returns:
    true if it is disk-based, false it it is in-memory only.

### getTraceSystem

    public TraceSystem getTraceSystem()

### getDataFile

    public DiskFile getDataFile()

### getIndexFile

    public DiskFile getIndexFile()

### setCacheSize

    public void setCacheSize(int kb)
                      throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### setMasterUser

    public void setMasterUser(User user)
                       throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getPublicRole

    public Role getPublicRole()

### getTempTableName

    public java.lang.String getTempTableName(Session session)

  Get a unique temporary table name.

  Parameters:
    `session` - the session
  Returns:
    a unique name

### setCompareMode

    public void setCompareMode(CompareMode compareMode)

### setCluster

    public void setCluster(java.lang.String cluster)

### checkWritingAllowed

    public void checkWritingAllowed()
                             throws java.sql.SQLException

  Description copied from interface: `DataHandler`
  Check if writing is allowed.

  Specified by:
    `checkWritingAllowed` in interface `DataHandler`
  Throws:
    `java.sql.SQLException` - if it is not allowed

### isReadOnly

    public boolean isReadOnly()

### setWriteDelay

    public void setWriteDelay(int value)

### deleteLogFileLater

    public void deleteLogFileLater(java.lang.String fileName)
                            throws java.sql.SQLException

  Delete an unused log file. It is deleted immediately if no writer thread is running, or deleted later on if one is running. Deleting is delayed because the hard drive otherwise may delete the file a bit before the data is written to the new file, which can cause problems when recovering.

  Parameters:
    `fileName` - the name of the file to be deleted
  Throws:
    `java.sql.SQLException`

### setEventListener

    public void setEventListener(DatabaseEventListener eventListener)

### setEventListenerClass

    public void setEventListenerClass(java.lang.String className)
                               throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### freeUpDiskSpace

    public void freeUpDiskSpace()
                         throws java.sql.SQLException

  Description copied from interface: `DataHandler`
  Free up disk space if possible. This method is called if more space is needed.

  Specified by:
    `freeUpDiskSpace` in interface `DataHandler`
  Throws:
    `java.sql.SQLException` - if no more space could be freed

### setProgress

    public void setProgress(int state,
                            java.lang.String name,
                            int x,
                            int max)

  Set the progress of a long running operation. This method calls the `DatabaseEventListener` if one is registered.

  Parameters:
    `state` - the `DatabaseEventListener` state
    `name` - the object name
    `x` - the current position
    `max` - the highest value

### exceptionThrown

    public void exceptionThrown(java.sql.SQLException e,
                                java.lang.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

### sync

    public void sync()
              throws java.sql.SQLException

  Synchronize the files with the file system. This method is called when executing the SQL statement CHECKPOINT SYNC.

  Throws:
    `java.sql.SQLException`

### getMaxMemoryRows

    public int getMaxMemoryRows()

### setMaxMemoryRows

    public void setMaxMemoryRows(int value)

### setMaxMemoryUndo

    public void setMaxMemoryUndo(int value)

### getMaxMemoryUndo

    public int getMaxMemoryUndo()

### setLockMode

    public void setLockMode(int lockMode)
                     throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getLockMode

    public int getLockMode()

### setCloseDelay

    public void setCloseDelay(int value)

### getLogIndexChanges

    public boolean getLogIndexChanges()

### setLog

    public void setLog(int level)
                throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getRecovery

    public boolean getRecovery()

### getSystemSession

    public Session getSystemSession()

### handleInvalidChecksum

    public void handleInvalidChecksum()
                               throws java.sql.SQLException

  Description copied from interface: `DataHandler`
  Called when the checksum was invalid.

  Specified by:
    `handleInvalidChecksum` in interface `DataHandler`
  Throws:
    `java.sql.SQLException` - if this should not be ignored

### isClosing

    public boolean isClosing()

  Check if the database is in the process of closing.

  Returns:
    true if the database is closing

### setMaxLengthInplaceLob

    public void setMaxLengthInplaceLob(int value)

### getMaxLengthInplaceLob

    public int getMaxLengthInplaceLob()

  Description copied from interface: `DataHandler`
  Get the maximum length of a in-place large object

  Specified by:
    `getMaxLengthInplaceLob` in interface `DataHandler`
  Returns:
    the maximum size

### setIgnoreCase

    public void setIgnoreCase(boolean b)

### getIgnoreCase

    public boolean getIgnoreCase()

### setDeleteFilesOnDisconnect

    public void setDeleteFilesOnDisconnect(boolean b)

### getLobCompressionAlgorithm

    public java.lang.String getLobCompressionAlgorithm(int type)

  Description copied from interface: `DataHandler`
  Get the compression algorithm used for large objects.

  Specified by:
    `getLobCompressionAlgorithm` in interface `DataHandler`
  Parameters:
    `type` - the data type (CLOB or BLOB)
  Returns:
    the compression algorithm, or null

### setLobCompressionAlgorithm

    public void setLobCompressionAlgorithm(java.lang.String stringValue)

### notifyFileSize

    public void notifyFileSize(long length)

  Called when the size if the data or index file has been changed.

  Parameters:
    `length` - the new file size

### setMaxLogSize

    public void setMaxLogSize(long value)

### setAllowLiterals

    public void setAllowLiterals(int value)

### getOptimizeReuseResults

    public boolean getOptimizeReuseResults()

### setOptimizeReuseResults

    public void setOptimizeReuseResults(boolean b)

### invalidateIndexSummary

    public void invalidateIndexSummary()
                                throws java.sql.SQLException

  Called when the summary of the index in the log file has become invalid. This method is only called if index changes are not logged, and if an index has been changed.

  Throws:
    `java.sql.SQLException`

### isIndexSummaryValid

    public boolean isIndexSummaryValid()

### getLobSyncObject

    public java.lang.Object getLobSyncObject()

  Description copied from interface: `DataHandler`
  Get the synchronization object for lob operations.

  Specified by:
    `getLobSyncObject` in interface `DataHandler`
  Returns:
    the synchronization object

### getSessionCount

    public int getSessionCount()

### setReferentialIntegrity

    public void setReferentialIntegrity(boolean b)

### getReferentialIntegrity

    public boolean getReferentialIntegrity()

### isStarting

    public 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

### isMultiVersion

    public boolean isMultiVersion()

  Check if multi version concurrency is enabled for this database.

  Returns:
    true if it is enabled

### opened

    public void opened()

  Called after the database has been opened and initialized. This method notifies the event listener if one has been set.

### setMode

    public void setMode(Mode mode)

### getMode

    public Mode getMode()

### isMultiThreaded

    public boolean isMultiThreaded()

### setMultiThreaded

    public void setMultiThreaded(boolean multiThreaded)
                          throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### setMaxOperationMemory

    public void setMaxOperationMemory(int maxOperationMemory)

### getMaxOperationMemory

    public int getMaxOperationMemory()

### getExclusiveSession

    public Session getExclusiveSession()

### setExclusiveSession

    public void setExclusiveSession(Session session)

### getLobFilesInDirectories

    public boolean getLobFilesInDirectories()

  Description copied from interface: `DataHandler`
  Checks if the lob files stored in directories.

  Specified by:
    `getLobFilesInDirectories` in interface `DataHandler`
  Returns:
    true if lob files are stored in directories.

### getLobFileListCache

    public SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()

  Description copied from interface: `DataHandler`
  Get the lob file list cache if it is used.

  Specified by:
    `getLobFileListCache` in interface `DataHandler`
  Returns:
    the cache or null

### isSysTableLocked

    public boolean isSysTableLocked()

  Checks if the system table (containing the catalog) is locked.

  Returns:
    true if it is currently locked

### getLinkConnection

    public TableLinkConnection getLinkConnection(java.lang.String driver,
                                                 java.lang.String url,
                                                 java.lang.String user,
                                                 java.lang.String password)
                                          throws java.sql.SQLException

  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
  Throws:
    `java.sql.SQLException`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### shutdownImmediately

    public void shutdownImmediately()

  Immediately close the database.

### getTempFileDeleter

    public TempFileDeleter getTempFileDeleter()

  Description copied from interface: `DataHandler`
  Get the temp file deleter mechanism.

  Specified by:
    `getTempFileDeleter` in interface `DataHandler`
  Returns:
    the temp file deleter

### getTrace

    public Trace getTrace()

  Description copied from interface: `DataHandler`
  Get the trace writer.

  Specified by:
    `getTrace` in interface `DataHandler`
  Returns:
    the trace writer

### getPageStore

    public PageStore getPageStore()
                           throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### isPageStoreEnabled

    public boolean isPageStoreEnabled()

### getFirstUserTable

    public Table getFirstUserTable()

  Get the first user defined table.

  Returns:
    the table or null if no table is defined

### isReconnectNeeded

    public 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

### checkpointIfRequired

    public void checkpointIfRequired()
                              throws java.sql.SQLException

  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.

  Throws:
    `java.sql.SQLException`

### isFileLockSerialized

    public boolean isFileLockSerialized()

### flushIndexes

    public void flushIndexes(long maxLastChange)

  Flush the indexes that were last changed prior to some time.

  Parameters:
    `maxLastChange` - indexes that were changed afterwards are not flushed; 0 to flush all indexes

### checkpoint

    public void checkpoint()
                    throws java.sql.SQLException

  Flush all changes and open a new log file.

  Throws:
    `java.sql.SQLException`

### beforeWriting

    public boolean beforeWriting()

  This method is called before writing to the log file.

  Returns:
    true if the call was successful and writing is allowed, false if another connection was faster

### afterWriting

    public void afterWriting()

  This method is called after updates are finished.

### setReadOnly

    public void setReadOnly(boolean readOnly)

  Switch the database to read-only mode.

  Parameters:
    `readOnly` - the new value

### setCompactFully

    public void setCompactFully(boolean compactFully)

### getCompiler

    public SourceCompiler getCompiler()