|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.engine.Database
public class Database
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
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. |
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()
|
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(int sessionId)
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 |
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 |
---|
public Database(java.lang.String name, ConnectionInfo ci, java.lang.String cipher) throws java.sql.SQLException
java.sql.SQLException
Method Detail |
---|
public static void setInitialPowerOffCount(int count)
public void setPowerOffCount(int count)
public boolean areEqual(Value a, Value b) throws java.sql.SQLException
a
- the first valueb
- the second value
java.sql.SQLException
public int compare(Value a, Value b) throws java.sql.SQLException
a
- the first valueb
- the second value
java.sql.SQLException
public int compareTypeSave(Value a, Value b) throws java.sql.SQLException
compareTypeSave
in interface DataHandler
a
- the first valueb
- the second value
java.sql.SQLException
public long getModificationDataId()
public long getNextModificationDataId()
public long getModificationMetaId()
public long getNextModificationMetaId()
public int getPowerOffCount()
public void checkPowerOff() throws java.sql.SQLException
DataHandler
checkPowerOff
in interface DataHandler
java.sql.SQLException
- if the simulated power failure occurredpublic static boolean exists(java.lang.String name)
name
- the name of the database (including path)
public Trace getTrace(java.lang.String module)
module
- the module name
public FileStore openFile(java.lang.String name, java.lang.String openMode, boolean mustExist) throws java.sql.SQLException
DataHandler
openFile
in interface DataHandler
name
- the file nameopenMode
- the modemustExist
- whether the file must already exist
java.sql.SQLException
public boolean validateFilePasswordHash(java.lang.String testCipher, byte[] testHash)
testCipher
- the cipher algorithmtestHash
- the hash code
public DataPage getDataPage()
public Schema getMainSchema()
public void removeStorage(int id, DiskFile file)
id
- the storage idfile
- the filepublic Storage getStorage(int id, DiskFile file)
id
- the storage idfile
- the file
public void removeMeta(Session session, int id) throws java.sql.SQLException
session
- the sessionid
- the id of the object to remove
java.sql.SQLException
public void addSchemaObject(Session session, SchemaObject obj) throws java.sql.SQLException
session
- the sessionobj
- the object to add
java.sql.SQLException
public void addDatabaseObject(Session session, DbObject obj) throws java.sql.SQLException
session
- the sessionobj
- the object to add
java.sql.SQLException
public UserAggregate findAggregate(java.lang.String name)
name
- the name of the user defined aggregate function
public Comment findComment(DbObject object)
object
- the database object
public FunctionAlias findFunctionAlias(java.lang.String name)
name
- the name of the user defined function
public Role findRole(java.lang.String roleName)
roleName
- the name of the role
public Schema findSchema(java.lang.String schemaName)
schemaName
- the name of the schema
public Setting findSetting(java.lang.String name)
name
- the name of the setting
public User findUser(java.lang.String name)
name
- the name of the user
public UserDataType findUserDataType(java.lang.String name)
name
- the name of the user defined data type
public User getUser(java.lang.String name) throws java.sql.SQLException
name
- the user name
java.sql.SQLException
- if the user does not existpublic Session createSession(User user) throws java.sql.SQLException
user
- the user
java.sql.SQLException
- if the database is in exclusive modepublic void removeSession(Session session)
session
- the sessionpublic int allocateObjectId(boolean needFresh, boolean dataFile)
DataHandler
allocateObjectId
in interface DataHandler
needFresh
- if a fresh id is requireddataFile
- true if the id is for the data file
public ObjectArray<UserAggregate> getAllAggregates()
public ObjectArray<Comment> getAllComments()
public ObjectArray<FunctionAlias> getAllFunctionAliases()
public int getAllowLiterals()
public ObjectArray<Right> getAllRights()
public ObjectArray<Role> getAllRoles()
public ObjectArray<SchemaObject> getAllSchemaObjects(int type)
type
- the object type
public ObjectArray<Table> getAllTablesAndViews()
public ObjectArray<Schema> getAllSchemas()
public ObjectArray<Setting> getAllSettings()
public ObjectArray<Storage> getAllStorages()
public ObjectArray<UserDataType> getAllUserDataTypes()
public ObjectArray<User> getAllUsers()
public java.lang.String getCacheType()
public int getChecksum(byte[] data, int start, int end)
DataHandler
getChecksum
in interface DataHandler
data
- the byte arraystart
- the starting offsetend
- the end offset
public java.lang.String getCluster()
public CompareMode getCompareMode()
public java.lang.String getDatabasePath()
DataHandler
getDatabasePath
in interface DataHandler
public java.lang.String getShortName()
public java.lang.String getName()
public LogSystem getLog()
public Session[] getSessions(boolean includingSystemSession)
includingSystemSession
- if the system session should also be
included
public void update(Session session, DbObject obj) throws java.sql.SQLException
session
- the sessionobj
- the database object
java.sql.SQLException
public void renameSchemaObject(Session session, SchemaObject obj, java.lang.String newName) throws java.sql.SQLException
session
- the sessionobj
- the objectnewName
- the new name
java.sql.SQLException
public void renameDatabaseObject(Session session, DbObject obj, java.lang.String newName) throws java.sql.SQLException
session
- the sessionobj
- the objectnewName
- the new name
java.sql.SQLException
public java.lang.String createTempFile() throws java.sql.SQLException
DataHandler
createTempFile
in interface DataHandler
java.sql.SQLException
public Storage getStorage(RecordReader reader, int id, boolean dataFile)
reader
- the record readerid
- the object iddataFile
- true if the data is in the data file
public Schema getSchema(java.lang.String schemaName) throws java.sql.SQLException
schemaName
- the name of the schema
java.sql.SQLException
- no schema with that name existspublic void removeDatabaseObject(Session session, DbObject obj) throws java.sql.SQLException
session
- the sessionobj
- the object to remove
java.sql.SQLException
public Table getDependentTable(SchemaObject obj, Table except)
obj
- the object to findexcept
- the table to exclude (or null)
public void removeSchemaObject(Session session, SchemaObject obj) throws java.sql.SQLException
session
- the sessionobj
- the object to be removed
java.sql.SQLException
public boolean isPersistent()
public TraceSystem getTraceSystem()
public DiskFile getDataFile()
public DiskFile getIndexFile()
public void setCacheSize(int kb) throws java.sql.SQLException
java.sql.SQLException
public void setMasterUser(User user) throws java.sql.SQLException
java.sql.SQLException
public Role getPublicRole()
public java.lang.String getTempTableName(int sessionId)
sessionId
- the session id
public void setCompareMode(CompareMode compareMode)
public void setCluster(java.lang.String cluster)
public void checkWritingAllowed() throws java.sql.SQLException
DataHandler
checkWritingAllowed
in interface DataHandler
java.sql.SQLException
- if it is not allowedpublic boolean isReadOnly()
public void setWriteDelay(int value)
public void deleteLogFileLater(java.lang.String fileName) throws java.sql.SQLException
fileName
- the name of the file to be deleted
java.sql.SQLException
public void setEventListener(DatabaseEventListener eventListener)
public void setEventListenerClass(java.lang.String className) throws java.sql.SQLException
java.sql.SQLException
public void freeUpDiskSpace() throws java.sql.SQLException
DataHandler
freeUpDiskSpace
in interface DataHandler
java.sql.SQLException
- if no more space could be freedpublic void setProgress(int state, java.lang.String name, int x, int max)
DatabaseEventListener
if one is registered.
state
- the DatabaseEventListener
statename
- the object namex
- the current positionmax
- the highest valuepublic void exceptionThrown(java.sql.SQLException e, java.lang.String sql)
e
- the exceptionsql
- the SQL statementpublic void sync() throws java.sql.SQLException
java.sql.SQLException
public int getMaxMemoryRows()
public void setMaxMemoryRows(int value)
public void setMaxMemoryUndo(int value)
public int getMaxMemoryUndo()
public void setLockMode(int lockMode) throws java.sql.SQLException
java.sql.SQLException
public int getLockMode()
public void setCloseDelay(int value)
public boolean getLogIndexChanges()
public void setLog(int level) throws java.sql.SQLException
java.sql.SQLException
public boolean getRecovery()
public Session getSystemSession()
public void handleInvalidChecksum() throws java.sql.SQLException
DataHandler
handleInvalidChecksum
in interface DataHandler
java.sql.SQLException
- if this should not be ignoredpublic boolean isClosing()
public void setMaxLengthInplaceLob(int value)
public int getMaxLengthInplaceLob()
DataHandler
getMaxLengthInplaceLob
in interface DataHandler
public void setIgnoreCase(boolean b)
public boolean getIgnoreCase()
public void setDeleteFilesOnDisconnect(boolean b)
public java.lang.String getLobCompressionAlgorithm(int type)
DataHandler
getLobCompressionAlgorithm
in interface DataHandler
type
- the data type (CLOB or BLOB)
public void setLobCompressionAlgorithm(java.lang.String stringValue)
public void notifyFileSize(long length)
length
- the new file sizepublic void setMaxLogSize(long value)
public void setAllowLiterals(int value)
public boolean getOptimizeReuseResults()
public void setOptimizeReuseResults(boolean b)
public void invalidateIndexSummary() throws java.sql.SQLException
java.sql.SQLException
public boolean isIndexSummaryValid()
public java.lang.Object getLobSyncObject()
DataHandler
getLobSyncObject
in interface DataHandler
public int getSessionCount()
public void setReferentialIntegrity(boolean b)
public boolean getReferentialIntegrity()
public boolean isStarting()
public boolean isMultiVersion()
public void opened()
public void setMode(Mode mode)
public Mode getMode()
public boolean isMultiThreaded()
public void setMultiThreaded(boolean multiThreaded) throws java.sql.SQLException
java.sql.SQLException
public void setMaxOperationMemory(int maxOperationMemory)
public int getMaxOperationMemory()
public Session getExclusiveSession()
public void setExclusiveSession(Session session)
public boolean getLobFilesInDirectories()
DataHandler
getLobFilesInDirectories
in interface DataHandler
public SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()
DataHandler
getLobFileListCache
in interface DataHandler
public boolean isSysTableLocked()
public TableLinkConnection getLinkConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password) throws java.sql.SQLException
driver
- the database driver or nullurl
- the database URLuser
- the user namepassword
- the password
java.sql.SQLException
public java.lang.String toString()
toString
in class java.lang.Object
public void shutdownImmediately()
public TempFileDeleter getTempFileDeleter()
DataHandler
getTempFileDeleter
in interface DataHandler
public Trace getTrace()
DataHandler
getTrace
in interface DataHandler
public PageStore getPageStore() throws java.sql.SQLException
java.sql.SQLException
public boolean isPageStoreEnabled()
public Table getFirstUserTable()
public boolean isReconnectNeeded()
public void checkpointIfRequired() throws java.sql.SQLException
java.sql.SQLException
public boolean isFileLockSerialized()
public void flushIndexes(long maxLastChange)
maxLastChange
- indexes that were changed
afterwards are not flushed; 0 to flush all indexespublic void checkpoint() throws java.sql.SQLException
java.sql.SQLException
public boolean beforeWriting()
public void setReadOnly(boolean readOnly)
readOnly
- the new value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |