public class Database extends Object implements DataHandler
Constructor and Description |
---|
Database(ConnectionInfo ci,
String cipher) |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
String |
createTempFile()
Create a temporary file in the database folder.
|
void |
exceptionThrown(SQLException e,
String sql)
This method is called after an exception occurred, to inform the database
event listener (if one is set).
|
UserAggregate |
findAggregate(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(String roleName)
Get the role if it exists, or null if not.
|
Schema |
findSchema(String schemaName)
Get the schema if it exists, or null if not.
|
Setting |
findSetting(String name)
Get the setting if it exists, or null if not.
|
User |
findUser(String name)
Get the user if it exists, or null if not.
|
UserDataType |
findUserDataType(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.
|
ArrayList<UserAggregate> |
getAllAggregates() |
ArrayList<Comment> |
getAllComments() |
int |
getAllowLiterals() |
ArrayList<Right> |
getAllRights() |
ArrayList<Role> |
getAllRoles() |
ArrayList<SchemaObject> |
getAllSchemaObjects()
Get all schema objects.
|
ArrayList<SchemaObject> |
getAllSchemaObjects(int type)
Get all schema objects of the given type.
|
ArrayList<Schema> |
getAllSchemas() |
ArrayList<Setting> |
getAllSettings() |
ArrayList<Table> |
getAllTablesAndViews(boolean includeMeta)
Get all tables and views.
|
ArrayList<UserDataType> |
getAllUserDataTypes() |
ArrayList<User> |
getAllUsers() |
String |
getCacheType() |
String |
getCluster() |
CompareMode |
getCompareMode() |
SourceCompiler |
getCompiler() |
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() |
ArrayList<InDoubtTransaction> |
getInDoubtTransactions()
Get the list of in-doubt transactions.
|
TableLinkConnection |
getLinkConnection(String driver,
String url,
String user,
String password)
Open a new connection or get an existing connection to another database.
|
String |
getLobCompressionAlgorithm(int type)
Get the compression algorithm used for large objects.
|
Connection |
getLobConnection()
Get a database connection to be used for LOB access.
|
SmallLRUCache<String,String[]> |
getLobFileListCache()
Get the lob file list cache if it is used.
|
LobStorage |
getLobStorage()
Get the lob storage mechanism to use.
|
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() |
String |
getName() |
long |
getNextModificationDataId() |
long |
getNextModificationMetaId() |
boolean |
getOptimizeReuseResults() |
PageStore |
getPageStore() |
int |
getPowerOffCount() |
Role |
getPublicRole() |
boolean |
getReferentialIntegrity() |
Schema |
getSchema(String schemaName)
Get the schema.
|
int |
getSessionCount() |
Session[] |
getSessions(boolean includingSystemSession)
Get all sessions that are currently connected to the database.
|
DbSettings |
getSettings() |
String |
getShortName() |
Session |
getSystemSession() |
TempFileDeleter |
getTempFileDeleter()
Get the temp file deleter mechanism.
|
String |
getTempTableName(String baseName,
Session session)
Get a unique temporary table name.
|
Trace |
getTrace(String module)
Get the trace object for the given module.
|
TraceSystem |
getTraceSystem() |
User |
getUser(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.
|
boolean |
lockMeta(Session session)
Lock the metadata table for updates.
|
FileStore |
openFile(String name,
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 |
renameDatabaseObject(Session session,
DbObject obj,
String newName)
Rename a database object.
|
void |
renameSchemaObject(Session session,
SchemaObject obj,
String newName)
Rename a schema object.
|
void |
setAllowLiterals(int value) |
void |
setCacheSize(int kb) |
void |
setCloseDelay(int value) |
void |
setCluster(String cluster) |
void |
setCompactMode(int compactMode) |
void |
setCompareMode(CompareMode compareMode) |
void |
setDefaultTableType(int defaultTableType) |
void |
setDeleteFilesOnDisconnect(boolean b) |
void |
setEventListener(DatabaseEventListener eventListener) |
void |
setEventListenerClass(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(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,
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.
|
String |
toString() |
void |
update(Session session,
DbObject obj)
Update an object in the system table.
|
void |
verifyMetaLocked(Session session)
Verify the meta table is locked.
|
public Database(ConnectionInfo ci, String cipher)
public static void setInitialPowerOffCount(int count)
public void setPowerOffCount(int count)
public boolean areEqual(Value a, Value b)
a
- the first valueb
- the second valuepublic int compare(Value a, Value b)
a
- the first valueb
- the second valuepublic int compareTypeSave(Value a, Value b)
a
- the first valueb
- the second valuepublic long getModificationDataId()
public long getNextModificationDataId()
public long getModificationMetaId()
public long getNextModificationMetaId()
public int getPowerOffCount()
public void checkPowerOff()
DataHandler
checkPowerOff
in interface DataHandler
public Trace getTrace(String module)
module
- the module namepublic FileStore openFile(String name, String openMode, boolean mustExist)
DataHandler
openFile
in interface DataHandler
name
- the file nameopenMode
- the modemustExist
- whether the file must already existpublic void verifyMetaLocked(Session session)
session
- the sessionpublic boolean lockMeta(Session session)
session
- the sessionpublic 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(String name)
name
- the name of the user defined aggregate functionpublic Comment findComment(DbObject object)
object
- the database objectpublic Role findRole(String roleName)
roleName
- the name of the rolepublic Schema findSchema(String schemaName)
schemaName
- the name of the schemapublic Setting findSetting(String name)
name
- the name of the settingpublic User findUser(String name)
name
- the name of the userpublic UserDataType findUserDataType(String name)
name
- the name of the user defined data typepublic User getUser(String name)
name
- the user nameDbException
- if the user does not existpublic void removeSession(Session session)
session
- the sessionpublic int allocateObjectId()
public ArrayList<UserAggregate> getAllAggregates()
public int getAllowLiterals()
public ArrayList<SchemaObject> getAllSchemaObjects()
public ArrayList<SchemaObject> getAllSchemaObjects(int type)
type
- the object typepublic ArrayList<Table> getAllTablesAndViews(boolean includeMeta)
includeMeta
- whether to force including the meta data tables (if
true, metadata tables are always included; if false, metadata
tables are only included if they are already initialized)public ArrayList<UserDataType> getAllUserDataTypes()
public String getCacheType()
public String getCluster()
public CompareMode getCompareMode()
public String getDatabasePath()
DataHandler
getDatabasePath
in interface DataHandler
public String getShortName()
public String getName()
public Session[] getSessions(boolean includingSystemSession)
includingSystemSession
- if the system session should also be
includedpublic void update(Session session, DbObject obj)
session
- the sessionobj
- the database objectpublic void renameSchemaObject(Session session, SchemaObject obj, String newName)
session
- the sessionobj
- the objectnewName
- the new namepublic void renameDatabaseObject(Session session, DbObject obj, String newName)
session
- the sessionobj
- the objectnewName
- the new namepublic String createTempFile()
public Schema getSchema(String schemaName)
schemaName
- the name of the schemaDbException
- 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 String getTempTableName(String baseName, Session session)
baseName
- the prefix of the returned namesession
- the sessionpublic void setCompareMode(CompareMode compareMode)
public void setCluster(String cluster)
public void checkWritingAllowed()
DataHandler
checkWritingAllowed
in interface DataHandler
public boolean isReadOnly()
public void setWriteDelay(int value)
public boolean getFlushOnEachCommit()
public ArrayList<InDoubtTransaction> getInDoubtTransactions()
public void flush()
public void setEventListener(DatabaseEventListener eventListener)
public void setEventListenerClass(String className)
public void freeUpDiskSpace()
DataHandler
freeUpDiskSpace
in interface DataHandler
public void setProgress(int state, 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(SQLException e, 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 String getLobCompressionAlgorithm(int type)
DataHandler
getLobCompressionAlgorithm
in interface DataHandler
type
- the data type (CLOB or BLOB)public void setLobCompressionAlgorithm(String stringValue)
public void setMaxLogSize(long value)
public void setAllowLiterals(int value)
public boolean getOptimizeReuseResults()
public void setOptimizeReuseResults(boolean b)
public 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 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<String,String[]> getLobFileListCache()
DataHandler
getLobFileListCache
in interface DataHandler
public boolean isSysTableLocked()
public TableLinkConnection getLinkConnection(String driver, String url, String user, String password)
driver
- the database driver or nullurl
- the database URLuser
- the user namepassword
- the passwordpublic void shutdownImmediately()
public TempFileDeleter getTempFileDeleter()
DataHandler
getTempFileDeleter
in interface DataHandler
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 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()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.