public final class Database extends java.lang.Object implements org.h2.store.DataHandler, CastDataProvider
Constructor and Description |
---|
Database(ConnectionInfo ci,
java.lang.String cipher) |
Modifier and Type | Method and Description |
---|---|
void |
addDatabaseObject(SessionLocal session,
DbObject obj)
Add an object to the database.
|
void |
addSchemaObject(SessionLocal session,
org.h2.schema.SchemaObject obj)
Add a schema object to the database.
|
int |
allocateObjectId()
Allocate a new object id.
|
void |
checkpoint()
Flush all changes and open a new transaction log.
|
void |
checkPowerOff()
Check if the simulated power failure occurred.
|
void |
checkWritingAllowed()
Check if writing is allowed.
|
org.h2.value.ValueTimestampTimeZone |
currentTimestamp()
Returns the current timestamp with maximum resolution.
|
org.h2.util.TimeZoneProvider |
currentTimeZone()
Returns the current time zone.
|
boolean |
equalsIdentifiers(java.lang.String a,
java.lang.String b)
Compare two identifiers (table names, column names,...) and verify they
are equal.
|
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).
|
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.
|
org.h2.schema.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.
|
RightOwner |
findUserOrRole(java.lang.String name)
Get the user or role if it exists, or
null if not. |
void |
flush()
Flush all pending changes to the transaction log.
|
java.util.ArrayList<Comment> |
getAllComments() |
int |
getAllowLiterals() |
java.util.ArrayList<Right> |
getAllRights() |
java.util.Collection<org.h2.schema.Schema> |
getAllSchemas() |
java.util.Collection<org.h2.schema.Schema> |
getAllSchemasNoMeta() |
java.util.Collection<Setting> |
getAllSettings() |
java.util.ArrayList<org.h2.table.TableSynonym> |
getAllSynonyms()
Get all synonyms.
|
java.util.ArrayList<org.h2.table.Table> |
getAllTablesAndViews()
Get all tables and views.
|
java.util.Collection<RightOwner> |
getAllUsersAndRoles() |
org.h2.security.auth.Authenticator |
getAuthenticator()
get authenticator for database users
|
java.lang.Throwable |
getBackgroundException() |
java.lang.String |
getCacheType() |
java.lang.String |
getCluster() |
org.h2.value.CompareMode |
getCompareMode()
Return compare mode.
|
org.h2.util.SourceCompiler |
getCompiler() |
java.lang.String |
getDatabasePath()
Get the database path.
|
org.h2.mode.DefaultNullOrdering |
getDefaultNullOrdering() |
int |
getDefaultTableType() |
org.h2.table.Table |
getDependentTable(org.h2.schema.SchemaObject obj,
org.h2.table.Table except)
Get the first table that depends on this object.
|
SessionLocal |
getExclusiveSession() |
org.h2.table.Table |
getFirstUserTable()
Get the first user defined table, excluding the LOB_BLOCKS table that the
Recover tool creates.
|
boolean |
getIgnoreCase() |
boolean |
getIgnoreCatalogs() |
java.util.ArrayList<org.h2.store.InDoubtTransaction> |
getInDoubtTransactions()
Get the list of in-doubt transactions.
|
JavaObjectSerializer |
getJavaObjectSerializer()
Returns the custom Java object serializer, or
null . |
org.h2.table.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.
|
org.h2.util.SmallLRUCache<java.lang.String,java.lang.String[]> |
getLobFileListCache()
Get the lob file list cache if it is used.
|
SessionLocal |
getLobSession() |
org.h2.store.LobStorageInterface |
getLobStorage()
Get the lob storage mechanism to use.
|
java.lang.Object |
getLobSyncObject()
Get the synchronization object for lob operations.
|
int |
getLockMode() |
int |
getLockTimeout() |
org.h2.schema.Schema |
getMainSchema()
Returns main schema (usually PUBLIC).
|
int |
getMaxLengthInplaceLob()
Get the maximum length of a in-place large object
|
int |
getMaxMemoryRows() |
int |
getMaxOperationMemory() |
Mode |
getMode()
Returns the database mode.
|
long |
getModificationDataId() |
long |
getModificationMetaId() |
java.lang.String |
getName() |
long |
getNextModificationDataId() |
long |
getNextModificationMetaId() |
long |
getNextRemoteSettingsId() |
boolean |
getOptimizeReuseResults() |
int |
getPageSize() |
int |
getPowerOffCount() |
Role |
getPublicRole() |
boolean |
getQueryStatistics() |
QueryStatisticsData |
getQueryStatisticsData() |
boolean |
getReferentialIntegrity() |
long |
getRemoteSettingsId() |
int |
getRetentionTime() |
org.h2.result.RowFactory |
getRowFactory() |
org.h2.schema.Schema |
getSchema(java.lang.String schemaName)
Get the schema.
|
int |
getSessionCount() |
SessionLocal[] |
getSessions(boolean includingSystemSession)
Get all sessions that are currently connected to the database.
|
DbSettings |
getSettings() |
java.lang.String |
getShortName() |
org.h2.mvstore.db.Store |
getStore() |
SessionLocal |
getSystemSession() |
User |
getSystemUser()
Returns system user.
|
TableEngine |
getTableEngine(java.lang.String tableEngine)
Get the table engine class, loading it if needed.
|
org.h2.util.TempFileDeleter |
getTempFileDeleter()
Get the temp file deleter mechanism.
|
java.lang.String |
getTempTableName(java.lang.String baseName,
SessionLocal session)
Get a unique temporary table name.
|
org.h2.message.Trace |
getTrace(int moduleId)
Get the trace object for the given module id.
|
org.h2.message.TraceSystem |
getTraceSystem() |
User |
getUser(java.lang.String name)
Get user with the given name.
|
int |
getWriteDelay() |
boolean |
isAllowBuiltinAliasOverride() |
boolean |
isClosing()
Check if the database is in the process of closing.
|
boolean |
isPersistent()
Check if this database is disk-based.
|
boolean |
isReadOnly() |
boolean |
isStarting()
Check if the database is currently opening.
|
boolean |
isSysTableLocked()
Checks if the system table (containing the catalog) is locked.
|
boolean |
isSysTableLockedBy(SessionLocal session)
Checks if the system table (containing the catalog) is locked by the
given session.
|
boolean |
lockMeta(SessionLocal session)
Lock the metadata table for updates.
|
<V> java.util.concurrent.ConcurrentHashMap<java.lang.String,V> |
newConcurrentStringMap()
Create a new hash map.
|
<V> java.util.HashMap<java.lang.String,V> |
newStringMap()
Create a new hash map.
|
<V> java.util.HashMap<java.lang.String,V> |
newStringMap(int initialCapacity)
Create a new hash map.
|
org.h2.store.FileStore |
openFile(java.lang.String name,
java.lang.String openMode,
boolean mustExist)
Open a file at the given location.
|
int |
readLob(long lobId,
byte[] hmac,
long offset,
byte[] buff,
int off,
int length)
Read from a lob.
|
void |
releaseDatabaseObjectIds(java.util.BitSet idsToRelease)
Mark some database ids as unused.
|
void |
removeDatabaseObject(SessionLocal session,
DbObject obj)
Remove the object from the database.
|
void |
removeMeta(SessionLocal session,
int id)
Remove the given object from the meta data.
|
void |
removeSchemaObject(SessionLocal session,
org.h2.schema.SchemaObject obj)
Remove an object from the system table.
|
void |
removeSession(SessionLocal session)
Remove a session.
|
void |
renameDatabaseObject(SessionLocal session,
DbObject obj,
java.lang.String newName)
Rename a database object.
|
void |
renameSchemaObject(SessionLocal session,
org.h2.schema.SchemaObject obj,
java.lang.String newName)
Rename a schema object.
|
void |
setAllowBuiltinAliasOverride(boolean b) |
void |
setAllowLiterals(int value) |
void |
setAuthenticator(org.h2.security.auth.Authenticator authenticator)
Set current database authenticator
|
void |
setBackgroundException(org.h2.message.DbException e) |
void |
setCacheSize(int kb) |
void |
setCloseDelay(int value) |
void |
setCluster(java.lang.String cluster) |
void |
setCompactMode(int compactMode) |
void |
setCompareMode(org.h2.value.CompareMode compareMode) |
void |
setDefaultNullOrdering(org.h2.mode.DefaultNullOrdering defaultNullOrdering) |
void |
setDefaultTableType(int defaultTableType) |
void |
setDeleteFilesOnDisconnect(boolean b) |
void |
setEventListener(DatabaseEventListener eventListener) |
void |
setEventListenerClass(java.lang.String className) |
boolean |
setExclusiveSession(SessionLocal session,
boolean closeOthers)
Set the session that can exclusively access the database.
|
void |
setIgnoreCase(boolean b) |
void |
setIgnoreCatalogs(boolean b) |
static void |
setInitialPowerOffCount(int count) |
void |
setJavaObjectSerializerName(java.lang.String serializerName) |
void |
setLockMode(int lockMode) |
void |
setMasterUser(User user) |
void |
setMaxLengthInplaceLob(int value) |
void |
setMaxMemoryRows(int value) |
void |
setMaxOperationMemory(int maxOperationMemory) |
void |
setMode(Mode mode) |
void |
setOptimizeReuseResults(boolean b) |
void |
setPowerOffCount(int count) |
void |
setProgress(int state,
java.lang.String name,
long x,
long max)
Set the progress of a long running operation.
|
void |
setQueryStatistics(boolean b) |
void |
setQueryStatisticsMaxEntries(int n) |
void |
setReadOnly(boolean readOnly)
Switch the database to read-only mode.
|
void |
setReferentialIntegrity(boolean b) |
void |
setRetentionTime(int value) |
void |
setRowFactory(org.h2.result.RowFactory rowFactory) |
void |
setWriteDelay(int value) |
void |
shutdownImmediately()
Immediately close the database.
|
void |
sync()
Synchronize the files with the file system.
|
java.lang.String |
sysIdentifier(java.lang.String upperName)
Returns identifier in upper or lower case depending on database settings.
|
java.lang.String |
toString() |
void |
unlockMeta(SessionLocal session)
Unlock the metadata table.
|
boolean |
unsetExclusiveSession(SessionLocal session)
Stop exclusive access the database by provided session.
|
void |
updateMeta(SessionLocal session,
DbObject obj)
Update an object in the system table.
|
void |
verifyMetaLocked(SessionLocal session)
Verify the meta table is locked.
|
boolean |
zeroBasedEnums()
Returns are ENUM values 0-based.
|
public Database(ConnectionInfo ci, java.lang.String cipher)
public int getLockTimeout()
public org.h2.result.RowFactory getRowFactory()
public void setRowFactory(org.h2.result.RowFactory rowFactory)
public static void setInitialPowerOffCount(int count)
public void setPowerOffCount(int count)
public org.h2.mvstore.db.Store getStore()
public long getModificationDataId()
public long getNextModificationDataId()
public long getModificationMetaId()
public long getNextModificationMetaId()
public long getRemoteSettingsId()
public long getNextRemoteSettingsId()
public int getPowerOffCount()
public void checkPowerOff()
org.h2.store.DataHandler
checkPowerOff
in interface org.h2.store.DataHandler
public org.h2.message.Trace getTrace(int moduleId)
moduleId
- the module idpublic org.h2.store.FileStore openFile(java.lang.String name, java.lang.String openMode, boolean mustExist)
org.h2.store.DataHandler
openFile
in interface org.h2.store.DataHandler
name
- the file nameopenMode
- the modemustExist
- whether the file must already existpublic void verifyMetaLocked(SessionLocal session)
session
- the sessionpublic boolean lockMeta(SessionLocal session)
session
- the sessionpublic void unlockMeta(SessionLocal session)
session
- the sessionpublic void removeMeta(SessionLocal session, int id)
session
- the sessionid
- the id of the object to removepublic void releaseDatabaseObjectIds(java.util.BitSet idsToRelease)
idsToRelease
- the ids to releasepublic void addSchemaObject(SessionLocal session, org.h2.schema.SchemaObject obj)
session
- the sessionobj
- the object to addpublic void addDatabaseObject(SessionLocal session, DbObject obj)
session
- the sessionobj
- the object to addpublic Comment findComment(DbObject object)
object
- the database objectpublic Role findRole(java.lang.String roleName)
roleName
- the name of the rolepublic org.h2.schema.Schema findSchema(java.lang.String schemaName)
schemaName
- the name of the schemapublic Setting findSetting(java.lang.String name)
name
- the name of the settingpublic User findUser(java.lang.String name)
name
- the name of the userpublic User getUser(java.lang.String name)
name
- the user nameorg.h2.message.DbException
- if the user does not existpublic RightOwner findUserOrRole(java.lang.String name)
null
if not.name
- the name of the user or rolenull
public void removeSession(SessionLocal session)
session
- the sessionpublic int allocateObjectId()
public User getSystemUser()
public org.h2.schema.Schema getMainSchema()
public java.util.ArrayList<Comment> getAllComments()
public int getAllowLiterals()
public java.util.ArrayList<Right> getAllRights()
public java.util.ArrayList<org.h2.table.Table> getAllTablesAndViews()
public java.util.ArrayList<org.h2.table.TableSynonym> getAllSynonyms()
public java.util.Collection<org.h2.schema.Schema> getAllSchemas()
public java.util.Collection<org.h2.schema.Schema> getAllSchemasNoMeta()
public java.util.Collection<Setting> getAllSettings()
public java.util.Collection<RightOwner> getAllUsersAndRoles()
public java.lang.String getCacheType()
public java.lang.String getCluster()
public org.h2.value.CompareMode getCompareMode()
org.h2.store.DataHandler
getCompareMode
in interface org.h2.store.DataHandler
public java.lang.String getDatabasePath()
org.h2.store.DataHandler
getDatabasePath
in interface org.h2.store.DataHandler
public java.lang.String getShortName()
public java.lang.String getName()
public SessionLocal[] getSessions(boolean includingSystemSession)
includingSystemSession
- if the system session should also be
includedpublic void updateMeta(SessionLocal session, DbObject obj)
session
- the sessionobj
- the database objectpublic void renameSchemaObject(SessionLocal session, org.h2.schema.SchemaObject obj, java.lang.String newName)
session
- the sessionobj
- the objectnewName
- the new namepublic void renameDatabaseObject(SessionLocal session, DbObject obj, java.lang.String newName)
session
- the sessionobj
- the objectnewName
- the new namepublic org.h2.schema.Schema getSchema(java.lang.String schemaName)
schemaName
- the name of the schemaorg.h2.message.DbException
- no schema with that name existspublic void removeDatabaseObject(SessionLocal session, DbObject obj)
session
- the sessionobj
- the object to removepublic org.h2.table.Table getDependentTable(org.h2.schema.SchemaObject obj, org.h2.table.Table except)
obj
- the object to findexcept
- the table to exclude (or null)public void removeSchemaObject(SessionLocal session, org.h2.schema.SchemaObject obj)
session
- the sessionobj
- the object to be removedpublic boolean isPersistent()
public org.h2.message.TraceSystem getTraceSystem()
public void setCacheSize(int kb)
public void setMasterUser(User user)
public Role getPublicRole()
public java.lang.String getTempTableName(java.lang.String baseName, SessionLocal session)
baseName
- the prefix of the returned namesession
- the sessionpublic void setCompareMode(org.h2.value.CompareMode compareMode)
public void setCluster(java.lang.String cluster)
public void checkWritingAllowed()
org.h2.store.DataHandler
checkWritingAllowed
in interface org.h2.store.DataHandler
public boolean isReadOnly()
public int getWriteDelay()
public void setWriteDelay(int value)
public int getRetentionTime()
public void setRetentionTime(int value)
public void setAllowBuiltinAliasOverride(boolean b)
public boolean isAllowBuiltinAliasOverride()
public java.util.ArrayList<org.h2.store.InDoubtTransaction> getInDoubtTransactions()
public void setBackgroundException(org.h2.message.DbException e)
public java.lang.Throwable getBackgroundException()
public void flush()
public void setEventListener(DatabaseEventListener eventListener)
public void setEventListenerClass(java.lang.String className)
public void setProgress(int state, java.lang.String name, long x, long max)
DatabaseEventListener
if one is registered.state
- the DatabaseEventListener
statename
- the object namex
- the current positionmax
- the highest value or 0 if unknownpublic 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 setLockMode(int lockMode)
public int getLockMode()
public void setCloseDelay(int value)
public SessionLocal getSystemSession()
public boolean isClosing()
public void setMaxLengthInplaceLob(int value)
public int getMaxLengthInplaceLob()
org.h2.store.DataHandler
getMaxLengthInplaceLob
in interface org.h2.store.DataHandler
public void setIgnoreCase(boolean b)
public boolean getIgnoreCase()
public void setIgnoreCatalogs(boolean b)
public boolean getIgnoreCatalogs()
public void setDeleteFilesOnDisconnect(boolean b)
public void setAllowLiterals(int value)
public boolean getOptimizeReuseResults()
public void setOptimizeReuseResults(boolean b)
public java.lang.Object getLobSyncObject()
org.h2.store.DataHandler
getLobSyncObject
in interface org.h2.store.DataHandler
public int getSessionCount()
public void setReferentialIntegrity(boolean b)
public boolean getReferentialIntegrity()
public void setQueryStatistics(boolean b)
public boolean getQueryStatistics()
public void setQueryStatisticsMaxEntries(int n)
public QueryStatisticsData getQueryStatisticsData()
public boolean isStarting()
public void setMode(Mode mode)
public Mode getMode()
CastDataProvider
getMode
in interface CastDataProvider
public void setDefaultNullOrdering(org.h2.mode.DefaultNullOrdering defaultNullOrdering)
public org.h2.mode.DefaultNullOrdering getDefaultNullOrdering()
public void setMaxOperationMemory(int maxOperationMemory)
public int getMaxOperationMemory()
public SessionLocal getExclusiveSession()
public boolean setExclusiveSession(SessionLocal session, boolean closeOthers)
session
- the sessioncloseOthers
- whether other sessions are closedpublic boolean unsetExclusiveSession(SessionLocal session)
session
- the sessionpublic org.h2.util.SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()
org.h2.store.DataHandler
getLobFileListCache
in interface org.h2.store.DataHandler
public boolean isSysTableLocked()
public boolean isSysTableLockedBy(SessionLocal session)
session
- the sessionpublic org.h2.table.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 passwordpublic java.lang.String toString()
toString
in class java.lang.Object
public void shutdownImmediately()
public org.h2.util.TempFileDeleter getTempFileDeleter()
org.h2.store.DataHandler
getTempFileDeleter
in interface org.h2.store.DataHandler
public org.h2.table.Table getFirstUserTable()
public void checkpoint()
public void setReadOnly(boolean readOnly)
readOnly
- the new valuepublic void setCompactMode(int compactMode)
public org.h2.util.SourceCompiler getCompiler()
public org.h2.store.LobStorageInterface getLobStorage()
org.h2.store.DataHandler
getLobStorage
in interface org.h2.store.DataHandler
public SessionLocal getLobSession()
public int getDefaultTableType()
public void setDefaultTableType(int defaultTableType)
public DbSettings getSettings()
public <V> java.util.HashMap<java.lang.String,V> newStringMap()
V
- the value typepublic <V> java.util.HashMap<java.lang.String,V> newStringMap(int initialCapacity)
V
- the value typeinitialCapacity
- the initial capacitypublic <V> java.util.concurrent.ConcurrentHashMap<java.lang.String,V> newConcurrentStringMap()
V
- the value typepublic boolean equalsIdentifiers(java.lang.String a, java.lang.String b)
a
- the first identifierb
- the second identifierpublic java.lang.String sysIdentifier(java.lang.String upperName)
upperName
- identifier in the upper casepublic int readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length)
org.h2.store.DataHandler
readLob
in interface org.h2.store.DataHandler
lobId
- the lob idhmac
- the message authentication codeoffset
- the offset within the lobbuff
- the target bufferoff
- the offset within the target bufferlength
- the number of bytes to readpublic int getPageSize()
public JavaObjectSerializer getJavaObjectSerializer()
CastDataProvider
null
.getJavaObjectSerializer
in interface CastDataProvider
null
public void setJavaObjectSerializerName(java.lang.String serializerName)
public TableEngine getTableEngine(java.lang.String tableEngine)
tableEngine
- the table engine namepublic org.h2.security.auth.Authenticator getAuthenticator()
public void setAuthenticator(org.h2.security.auth.Authenticator authenticator)
authenticator
- = authenticator to set, null to revert to the Internal
authenticatorpublic org.h2.value.ValueTimestampTimeZone currentTimestamp()
CastDataProvider
currentTimestamp
in interface CastDataProvider
public org.h2.util.TimeZoneProvider currentTimeZone()
CastDataProvider
currentTimeZone
in interface CastDataProvider
public boolean zeroBasedEnums()
CastDataProvider
zeroBasedEnums
in interface CastDataProvider