public class DatabaseConnection extends Object implements TriggerListener
Modifier and Type | Class and Description |
---|---|
static interface |
DatabaseConnection.CallBack
Call back interface for events that occur within the connection instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCheckConstraint(TableName table_name,
Expression expression,
short deferred,
String constraint_name)
Same as the Transaction.addCheckConstraint method.
|
void |
addForeignKeyConstraint(TableName table,
String[] cols,
TableName ref_table,
String[] ref_cols,
String delete_rule,
String update_rule,
short deferred,
String constraint_name)
Same as the Transaction.addForeignKeyConstraint method.
|
void |
addPrimaryKeyConstraint(TableName table_name,
String[] cols,
short deferred,
String constraint_name)
Same as the Transaction.addPrimaryKeyConstraint method.
|
void |
addSelectedFromTable(String table_name)
Adds the given table name to the list of tables that are selected from
within the transaction in this connection.
|
void |
addSelectedFromTable(TableName name)
Adds the given table name to the list of tables that are selected from
within the transaction in this connection.
|
void |
addUniqueConstraint(TableName table_name,
String[] cols,
short deferred,
String constraint_name)
Same as the Transaction.addUniqueConstraint method.
|
void |
alterCreateTable(DataTableDef table_def)
Given a DataTableDef, if the table exists then it is updated otherwise
if it doesn't exist then it is created.
|
void |
alterCreateTable(DataTableDef table_def,
int data_sector_size,
int index_sector_size)
Given a DataTableDef, if the table exists then it is updated otherwise
if it doesn't exist then it is created.
|
void |
checkAllConstraints(TableName table_name)
Checks all the rows in the table for immediate constraint violations
and when the transaction is next committed check for all deferred
constraint violations.
|
void |
close()
Closes this database connection.
|
void |
commit()
Tries to commit the current transaction.
|
void |
compactTable(String table_name)
Compacts the table with the given name.
|
void |
compactTable(TableName table_name)
Compacts the table with the given name.
|
Ref |
createNewLargeObject(byte type,
long object_size)
Allocates a new large object in the Blob store of this conglomerate of the
given type and size.
|
QueryPlanNode |
createObjectFetchQueryPlan(TableName table_name,
TableName aliased_name)
Creates a QueryPlanNode to fetch the given table object from this
connection.
|
void |
createSchema(String name,
String type)
Same as the Transaction.createSchema method.
|
void |
createSequenceGenerator(TableName name,
long start_value,
long increment_by,
long min_value,
long max_value,
long cache,
boolean cycle)
Creates a new sequence generator with the given TableName and
initializes it with the given details.
|
void |
createTable(DataTableDef table_def)
Create a new table within the context of the current connection
transaction.
|
void |
createTable(DataTableDef table_def,
int data_sector_size,
int index_sector_size)
Create a new table with a starting initial sector size.
|
void |
createTrigger(String trigger_name,
String trigger_source,
int type)
Adds a type of trigger for the given trigger source (usually the
name of the table).
|
void |
createView(SQLQuery query,
ViewDef view)
Creates a new view.
|
DebugLogger |
Debug()
Returns a DebugLogger object that we can use to log debug messages to.
|
void |
deleteTrigger(String trigger_name)
Removes a type of trigger for the given trigger source (usually the
name of the table).
|
void |
dropAllConstraintsForTable(TableName table_name)
Same as the Transaction.dropAllConstraintsForTable method.
|
int |
dropNamedConstraint(TableName table_name,
String constraint_name)
Same as the Transaction.dropNamedConstraint method.
|
boolean |
dropPrimaryKeyConstraintForTable(TableName table_name,
String constraint_name)
Same as the Transaction.dropPrimaryKeyConstraintForTable method.
|
void |
dropSchema(String name)
Same as the Transaction.dropSchema method.
|
void |
dropSequenceGenerator(TableName name)
Drops an existing sequence generator with the given name.
|
void |
dropTable(String table_name)
Drops a table from within the context of the current connection
transaction.
|
void |
dropTable(TableName table_name)
Drops a table from within the context of the current connection
transaction.
|
boolean |
dropView(TableName view_name)
Drops the view with the given name and returns true if the drop succeeded.
|
void |
finalize() |
void |
fireTrigger(DatabaseConnection database,
String trigger_name,
TriggerEvent evt)
Notifies when a trigger has fired for this user.
|
void |
flushBlobStore()
Tells the conglomerate to flush the blob store.
|
boolean |
getAutoCommit()
Returns the auto-commit status of this connection.
|
ConnectionTriggerManager |
getConnectionTriggerManager()
Returns the connection trigger manager for this connection.
|
String |
getCurrentSchema()
Returns the name of the schema that this connection is within.
|
Database |
getDatabase()
Returns the Database object for this connection.
|
DataTableDef |
getDataTableDef(TableName name)
Returns the DataTableDef for the table with the given name.
|
GrantManager |
getGrantManager()
Returns the GrantManager object that manages grants for tables in the
database for this connection/user.
|
Connection |
getJDBCConnection()
Returns a java.sql.Connection object that can be used as a JDBC
interface to access the current transaction of this DatabaseConnection.
|
LockingMechanism |
getLockingMechanism()
Returns the LockingMechanism object that is within the context of this
database connection.
|
String |
getPersistentVar(String variable)
Same as the Transaction.getPersistentVar method.
|
ProcedureManager |
getProcedureManager()
Returns the ProcedureManager object that manages database functions and
procedures in the database for this connection/user.
|
SchemaDef[] |
getSchemaList()
Same as the Transaction.getSchemaList method.
|
DatabaseSystem |
getSystem()
Returns the DatabaseSystem object for this connection.
|
DataTable |
getTable(String table_name)
Returns a DataTable that represents the table with the given name in the
database from the current connection schema.
|
DataTable |
getTable(TableName name)
Returns a DataTable that represents the table from the given schema,
name in the database.
|
TableName[] |
getTableList()
Returns a TableName[] array that contains the list of database
tables that are visible by this transaction.
|
TableQueryDef |
getTableQueryDef(TableName table_name,
TableName aliased_as)
Returns a TableQueryDef object that describes the characteristics of a
table including the name (TableName), the columns (DataTableDef) and the
query plan to produce the table (QueryPlanNode).
|
String |
getTableType(TableName table_name)
Returns the type of the table object.
|
int |
getTransactionIsolation()
Returns the transaction isolation level of this connection.
|
String |
getTransactionIsolationAsString()
Returns the transaction isolation level of this connection as a string.
|
User |
getUser()
Returns the User object for this connection.
|
boolean |
isInCaseInsensitiveMode()
Returns true if the connection is in case insensitive mode.
|
long |
lastSequenceValue(String name)
Returns the current sequence value for the given sequence generator that
was last returned by a call to 'nextSequenceValue'.
|
long |
nextSequenceValue(String name)
Requests of the sequence generator the next value from the sequence.
|
long |
nextUniqueID(String table_name)
Returns the next unique identifier for the given table in the connection
schema.
|
long |
nextUniqueID(TableName name)
Returns the next unique identifier for the given table from the schema.
|
void |
notifyTriggerEvent(TriggerEvent evt)
Informs the underlying transaction that a high level transaction event
has occurred and should be dispatched to any listeners occordingly.
|
Transaction.CheckExpression[] |
queryTableCheckExpressions(TableName table_name)
Same as the Transaction.queryTableCheckExpression method.
|
Transaction.ColumnGroupReference[] |
queryTableForeignKeyReferences(TableName table_name)
Same as the Transaction.queryTableForeignKeyReferences method.
|
Transaction.ColumnGroupReference[] |
queryTableImportedForeignKeyReferences(TableName table_name)
Same as the Transaction.queryTableImportedForeignKeyReferences method.
|
Transaction.ColumnGroup |
queryTablePrimaryKeyGroup(TableName table_name)
Same as the Transaction.queryTablePrimaryKeyGroup method.
|
TableName[] |
queryTablesRelationallyLinkedTo(TableName table)
Same as the Transaction.queryTablesRelationallyLinkedTo method.
|
Transaction.ColumnGroup[] |
queryTableUniqueGroups(TableName table_name)
Same as the Transaction.queryTableUniqueGroups method.
|
SchemaDef |
resolveSchemaCase(String name,
boolean ignore_case)
Same as the Transaction.resolveSchemaCase method.
|
SchemaDef |
resolveSchemaName(String name)
Convenience - returns the SchemaDef object given the name of the schema.
|
TableName |
resolveTableName(String name)
Resolves a TableName string (eg.
|
TableName |
resolveToTableName(String name)
Resolves the given string to a table name, throwing an exception if
the reference is ambiguous.
|
void |
rollback()
Rolls back the current transaction operating within this connection.
|
boolean |
schemaExists(String name)
Same as the Transaction.schemaExists method.
|
void |
setAutoCommit(boolean status)
Sets the auto-commit mode.
|
void |
setCurrentSchema(String current_schema)
Sets the schema that this connection is within.
|
void |
setDefaultSchema(String schema_name)
Changes the default schema to the given schema.
|
void |
setPersistentVar(String variable,
String value)
Same as the Transaction.setPersistentVar method.
|
void |
setSequenceValue(String name,
long value)
Sets the sequence value for the given sequence generator.
|
void |
setTransactionIsolation(String name)
Sets the transaction isolation level from a string.
|
void |
setVar(String name,
Expression exp)
Assigns a variable to the expression for this connection.
|
boolean |
tableExists(String table_name)
Returns true if the table exists within this connection transaction.
|
boolean |
tableExists(TableName table_name)
Returns true if the table exists within this connection transaction.
|
TableName |
tryResolveCase(TableName table_name)
Attempts to resolve the given table name to its correct case assuming
the table name represents a case insensitive version of the name.
|
void |
updateTable(DataTableDef table_def)
Updates a given table within the context of the current connection
transaction.
|
void |
updateTable(DataTableDef table_def,
int data_sector_size,
int index_sector_size)
Updates a given table within the context of the current connection
transaction.
|
public Connection getJDBCConnection()
There are a few important considerations when using the JDBC connection;
public DatabaseSystem getSystem()
public Database getDatabase()
public User getUser()
public final DebugLogger Debug()
public ConnectionTriggerManager getConnectionTriggerManager()
public GrantManager getGrantManager()
public ProcedureManager getProcedureManager()
public void setAutoCommit(boolean status)
public void setTransactionIsolation(String name)
public void setVar(String name, Expression exp)
ERROR_ON_DIRTY_SELECT - set to Boolean.TRUE for turning this transaction conflict off on this connection. CASE_INSENSITIVE_IDENTIFIERS - Boolean.TRUE means the grammar becomes case insensitive for identifiers resolved by the grammar.
public boolean getAutoCommit()
public int getTransactionIsolation()
public String getTransactionIsolationAsString()
public String getCurrentSchema()
public boolean isInCaseInsensitiveMode()
public void setCurrentSchema(String current_schema)
public LockingMechanism getLockingMechanism()
public TableName[] getTableList()
This returns the list of all objects that represent queriable tables in the database.
public boolean tableExists(String table_name)
public boolean tableExists(TableName table_name)
public String getTableType(TableName table_name)
public TableName tryResolveCase(TableName table_name)
public TableName resolveTableName(String name)
public TableName resolveToTableName(String name)
public DataTableDef getDataTableDef(TableName name)
public DataTable getTable(TableName name)
public DataTable getTable(String table_name)
public void createTable(DataTableDef table_def)
public void createTable(DataTableDef table_def, int data_sector_size, int index_sector_size)
public void createView(SQLQuery query, ViewDef view)
Note that this is a transactional operation. You need to commit for the view to be visible to other transactions.
public boolean dropView(TableName view_name)
Note that this is a transactional operation. You need to commit for the change to be visible to other transactions.
public void updateTable(DataTableDef table_def)
public void updateTable(DataTableDef table_def, int data_sector_size, int index_sector_size)
public void alterCreateTable(DataTableDef table_def, int data_sector_size, int index_sector_size)
This should only be used as very fine grain optimization for creating/ altering tables. If in the future the underlying table model is changed so that the given 'sector_size' value is unapplicable, then the value will be ignored.
public void alterCreateTable(DataTableDef table_def)
public void checkAllConstraints(TableName table_name)
public void dropTable(String table_name)
public void dropTable(TableName table_name)
public void compactTable(String table_name)
public void compactTable(TableName table_name)
public void addSelectedFromTable(String table_name)
public void addSelectedFromTable(TableName name)
public long nextSequenceValue(String name)
NOTE: This does NOT check that the user owning this connection has the correct privs to perform this operation.
public long lastSequenceValue(String name)
NOTE: This does NOT check that the user owning this connection has the correct privs to perform this operation.
public void setSequenceValue(String name, long value)
NOTE: This does NOT check that the user owning this connection has the correct privs to perform this operation.
public long nextUniqueID(TableName name)
public long nextUniqueID(String table_name)
public void createSequenceGenerator(TableName name, long start_value, long increment_by, long min_value, long max_value, long cache, boolean cycle)
public void dropSequenceGenerator(TableName name)
public void createTrigger(String trigger_name, String trigger_source, int type)
Adds a type of trigger to the given Table. When the event is fired, the UserCallBack method is notified of the event.
public void deleteTrigger(String trigger_name)
public void notifyTriggerEvent(TriggerEvent evt)
public Ref createNewLargeObject(byte type, long object_size)
Once a large object is created and written to, it may be allocated in one or more tables in the conglomerate.
public void flushBlobStore()
If this is not called and the database closes (or crashes) before a flush occurs then the blob may not be recoverable.
public TableQueryDef getTableQueryDef(TableName table_name, TableName aliased_as)
This produces TableQueryDef objects for all table objects in the database including data tables and views.
The 'aliased_as' parameter is used to overwrite the default name of the table object.
public QueryPlanNode createObjectFetchQueryPlan(TableName table_name, TableName aliased_name)
public void setDefaultSchema(String schema_name)
public void createSchema(String name, String type)
public void dropSchema(String name)
public boolean schemaExists(String name)
public SchemaDef resolveSchemaCase(String name, boolean ignore_case)
public SchemaDef resolveSchemaName(String name)
public SchemaDef[] getSchemaList()
public void setPersistentVar(String variable, String value)
public String getPersistentVar(String variable)
public void addUniqueConstraint(TableName table_name, String[] cols, short deferred, String constraint_name)
public void addForeignKeyConstraint(TableName table, String[] cols, TableName ref_table, String[] ref_cols, String delete_rule, String update_rule, short deferred, String constraint_name)
public void addPrimaryKeyConstraint(TableName table_name, String[] cols, short deferred, String constraint_name)
public void addCheckConstraint(TableName table_name, Expression expression, short deferred, String constraint_name)
public void dropAllConstraintsForTable(TableName table_name)
public int dropNamedConstraint(TableName table_name, String constraint_name)
public boolean dropPrimaryKeyConstraintForTable(TableName table_name, String constraint_name)
public TableName[] queryTablesRelationallyLinkedTo(TableName table)
public Transaction.ColumnGroup[] queryTableUniqueGroups(TableName table_name)
public Transaction.ColumnGroup queryTablePrimaryKeyGroup(TableName table_name)
public Transaction.CheckExpression[] queryTableCheckExpressions(TableName table_name)
public Transaction.ColumnGroupReference[] queryTableForeignKeyReferences(TableName table_name)
public Transaction.ColumnGroupReference[] queryTableImportedForeignKeyReferences(TableName table_name)
public void fireTrigger(DatabaseConnection database, String trigger_name, TriggerEvent evt)
fireTrigger
in interface TriggerListener
database
- the DatabaseConnection that this trigger is registered
for.evt
- the trigger event that was fired.public void commit() throws TransactionException
NOTE: It's guarenteed that the transaction will be closed even if a transaction exception occurs.
Synchronization is implied on this method, because the locking mechanism should be exclusive when this is called.
TransactionException
public void rollback()
NOTE: It's guarenteed that the transaction will be closed even if an exception occurs.
Synchronization is implied on this method, because the locking mechanism should be exclusive when this is called.
public void close()
Copyright © 2015. All rights reserved.