|
||||||||||
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, 0, objectType int, sql varchar
Constructor Summary | |
---|---|
Database(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()
Allocate a new 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 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 |
checkPowerOff()
Check if the simulated power failure occurred. |
void |
checkWritingAllowed()
Check if writing is allowed. |
void |
commit(Session session)
Commit the current transaction of the given session. |
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 in the database folder. |
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. |
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 |
flush()
Flush all pending changes to the transaction log. |
void |
freeUpDiskSpace()
Free up disk space if possible. |
java.util.ArrayList<UserAggregate> |
getAllAggregates()
|
java.util.ArrayList<Comment> |
getAllComments()
|
int |
getAllowLiterals()
|
java.util.ArrayList<Right> |
getAllRights()
|
java.util.ArrayList<Role> |
getAllRoles()
|
java.util.ArrayList<SchemaObject> |
getAllSchemaObjects()
Get all schema objects. |
java.util.ArrayList<SchemaObject> |
getAllSchemaObjects(int type)
Get all schema objects of the given type. |
java.util.ArrayList<Schema> |
getAllSchemas()
|
java.util.ArrayList<Setting> |
getAllSettings()
|
java.util.ArrayList<Table> |
getAllTablesAndViews(boolean includeMeta)
Get all tables and views. |
java.util.ArrayList<UserDataType> |
getAllUserDataTypes()
|
java.util.ArrayList<User> |
getAllUsers()
|
java.lang.String |
getCacheType()
|
java.lang.String |
getCluster()
|
CompareMode |
getCompareMode()
|
SourceCompiler |
getCompiler()
|
java.lang.String |
getDatabasePath()
Get the database path. |
int |
getDefaultTableType()
|
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 |
getFlushOnEachCommit()
Check if flush-on-each-commit is enabled. |
boolean |
getIgnoreCase()
|
java.util.ArrayList<InDoubtTransaction> |
getInDoubtTransactions()
Get the list of in-doubt transactions. |
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. |
java.sql.Connection |
getLobConnection()
Get a database connection to be used for LOB access. |
SmallLRUCache<java.lang.String,java.lang.String[]> |
getLobFileListCache()
Get the lob file list cache if it is used. |
LobStorage |
getLobStorage()
Get the lob storage mechanism to use. |
java.lang.Object |
getLobSyncObject()
Get the synchronization object for lob operations. |
int |
getLockMode()
|
int |
getLogMode()
|
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 |
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. |
DbSettings |
getSettings()
|
java.lang.String |
getShortName()
|
Session |
getSystemSession()
|
TempFileDeleter |
getTempFileDeleter()
Get the temp file deleter mechanism. |
java.lang.String |
getTempTableName(Session session)
Get a unique temporary table name. |
Trace |
getTrace()
|
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. |
boolean |
isClosing()
Check if the database is in the process of closing. |
boolean |
isFileLockSerialized()
|
boolean |
isMultiThreaded()
|
boolean |
isMultiVersion()
Check if multi version concurrency is enabled for this database. |
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 |
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 |
prepareCommit(Session session,
java.lang.String transaction)
Prepare a transaction. |
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 |
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 |
setCompactMode(int compactMode)
|
void |
setCompareMode(CompareMode compareMode)
|
void |
setDefaultTableType(int defaultTableType)
|
void |
setDeleteFilesOnDisconnect(boolean b)
|
void |
setEventListener(DatabaseEventListener eventListener)
|
void |
setEventListenerClass(java.lang.String className)
|
void |
setExclusiveSession(Session session,
boolean closeOthers)
Set the session that can exclusively access the database. |
void |
setIgnoreCase(boolean b)
|
static void |
setInitialPowerOffCount(int count)
|
void |
setLobCompressionAlgorithm(java.lang.String stringValue)
|
void |
setLockMode(int lockMode)
|
void |
setLogMode(int log)
|
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 |
setMultiVersion(boolean multiVersion)
|
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(ConnectionInfo ci, java.lang.String cipher)
Method Detail |
---|
public static void setInitialPowerOffCount(int count)
public void setPowerOffCount(int count)
public boolean areEqual(Value a, Value b)
a
- the first valueb
- the second value
public int compare(Value a, Value b)
a
- the first valueb
- the second value
public int compareTypeSave(Value a, Value b)
a
- the first valueb
- the second value
public long getModificationDataId()
public long getNextModificationDataId()
public long getModificationMetaId()
public long getNextModificationMetaId()
public int getPowerOffCount()
public void checkPowerOff()
DataHandler
checkPowerOff
in interface DataHandler
public 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)
DataHandler
openFile
in interface DataHandler
name
- the file nameopenMode
- the modemustExist
- whether the file must already exist
public boolean validateFilePasswordHash(java.lang.String testCipher, byte[] testHash)
testCipher
- the cipher algorithmtestHash
- the hash code
public void removeMeta(Session session, int id)
session
- the sessionid
- the id of the object to removepublic void addSchemaObject(Session session, SchemaObject obj)
session
- the sessionobj
- the object to addpublic void addDatabaseObject(Session session, DbObject obj)
session
- the sessionobj
- the object to addpublic 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 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)
name
- the user name
java.sql.SQLException
- if the user does not existpublic Session createSession(User user)
user
- the user
java.sql.SQLException
- if the database is in exclusive modepublic void removeSession(Session session)
session
- the sessionpublic int allocateObjectId()
public java.util.ArrayList<UserAggregate> getAllAggregates()
public java.util.ArrayList<Comment> getAllComments()
public int getAllowLiterals()
public java.util.ArrayList<Right> getAllRights()
public java.util.ArrayList<Role> getAllRoles()
public java.util.ArrayList<SchemaObject> getAllSchemaObjects()
public java.util.ArrayList<SchemaObject> getAllSchemaObjects(int type)
type
- the object type
public java.util.ArrayList<Table> getAllTablesAndViews(boolean includeMeta)
includeMeta
- whether to include the meta data tables
public java.util.ArrayList<Schema> getAllSchemas()
public java.util.ArrayList<Setting> getAllSettings()
public java.util.ArrayList<UserDataType> getAllUserDataTypes()
public java.util.ArrayList<User> getAllUsers()
public java.lang.String getCacheType()
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 Session[] getSessions(boolean includingSystemSession)
includingSystemSession
- if the system session should also be
included
public void update(Session session, DbObject obj)
session
- the sessionobj
- the database objectpublic void renameSchemaObject(Session session, SchemaObject obj, java.lang.String newName)
session
- the sessionobj
- the objectnewName
- the new namepublic void renameDatabaseObject(Session session, DbObject obj, java.lang.String newName)
session
- the sessionobj
- the objectnewName
- the new namepublic java.lang.String createTempFile()
public Schema getSchema(java.lang.String schemaName)
schemaName
- the name of the schema
java.sql.SQLException
- no schema with that name existspublic void removeDatabaseObject(Session session, DbObject obj)
session
- the sessionobj
- the object to removepublic Table getDependentTable(SchemaObject obj, Table except)
obj
- the object to findexcept
- the table to exclude (or null)
public void removeSchemaObject(Session session, SchemaObject obj)
session
- the sessionobj
- the object to be removedpublic boolean isPersistent()
public TraceSystem getTraceSystem()
public void setCacheSize(int kb)
public void setMasterUser(User user)
public Role getPublicRole()
public java.lang.String getTempTableName(Session session)
session
- the session
public void setCompareMode(CompareMode compareMode)
public void setCluster(java.lang.String cluster)
public void checkWritingAllowed()
DataHandler
checkWritingAllowed
in interface DataHandler
public boolean isReadOnly()
public void setWriteDelay(int value)
public boolean getFlushOnEachCommit()
public java.util.ArrayList<InDoubtTransaction> getInDoubtTransactions()
public void prepareCommit(Session session, java.lang.String transaction)
session
- the sessiontransaction
- the name of the transactionpublic void commit(Session session)
session
- the sessionpublic void flush()
public void setEventListener(DatabaseEventListener eventListener)
public void setEventListenerClass(java.lang.String className)
public void freeUpDiskSpace()
DataHandler
freeUpDiskSpace
in interface DataHandler
public 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()
public int getMaxMemoryRows()
public void setMaxMemoryRows(int value)
public void setMaxMemoryUndo(int value)
public int getMaxMemoryUndo()
public void setLockMode(int lockMode)
public int getLockMode()
public void setCloseDelay(int value)
public Session getSystemSession()
public 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 setMaxLogSize(long value)
public void setAllowLiterals(int value)
public boolean getOptimizeReuseResults()
public void setOptimizeReuseResults(boolean b)
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)
public void setMaxOperationMemory(int maxOperationMemory)
public int getMaxOperationMemory()
public Session getExclusiveSession()
public void setExclusiveSession(Session session, boolean closeOthers)
session
- the sessioncloseOthers
- whether other sessions are closedpublic 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)
driver
- the database driver or nullurl
- the database URLuser
- the user namepassword
- the password
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()
public PageStore getPageStore()
public Table getFirstUserTable()
public boolean isReconnectNeeded()
public void checkpointIfRequired()
public boolean isFileLockSerialized()
public void checkpoint()
public boolean beforeWriting()
public void afterWriting()
public void setReadOnly(boolean readOnly)
readOnly
- the new valuepublic void setCompactMode(int compactMode)
public SourceCompiler getCompiler()
public LobStorage getLobStorage()
DataHandler
getLobStorage
in interface DataHandler
public java.sql.Connection getLobConnection()
DataHandler
getLobConnection
in interface DataHandler
public void setLogMode(int log)
public int getLogMode()
public int getDefaultTableType()
public void setDefaultTableType(int defaultTableType)
public void setMultiVersion(boolean multiVersion)
public DbSettings getSettings()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |