public abstract class AbstractDatabase extends AbstractDBObjectProvider implements Database
Database interface.
 AbstractDatabase can be subclassed to provide support for specific
 types of databases.CASE_SENSITIVE_NAME_POLICY, EMPTY_LIST, LOWER_CASE_NAME_POLICY, MIXED_CASE_NAME_POLICY, NEW_FROM_TEMPLATE_TYPE, TIMESTAMP_PROPERTY, UPPER_CASE_NAME_POLICYFOUR_GIG, GENERIC_JDBC_DATABASE, PROVIDER_TYPE, SOURCE_TYPE_BODY, SOURCE_TYPE_SPEC, TWO_GIGCREATE_PRIVILEDGE, DELETE_PRIVILEDGE, MODIFY_PRIVILEDGE, NEW_FROM_TEMPLATE_TYPE| Modifier | Constructor and Description | 
|---|---|
protected  | 
AbstractDatabase(java.lang.String connStore,
                java.lang.String connName,
                java.sql.Connection conn)
Constructs a new AbstractDatabase with the given connection
 information. 
 | 
protected  | 
AbstractDatabase(java.lang.String connStore,
                java.lang.String connName,
                java.sql.Connection conn,
                java.lang.String type,
                int version)
Constructs a new AbstractDatabase with the given connection
 information. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
cancelStatement()
Cancels the Statement currently executing against this Database if:
 
  such a statement has been recorded by the use of a
  
StatementWrapper/QueryWrapper
  both the DBMS and driver support aborting an SQL statement
  | 
boolean | 
canRestrictSchemaList()
Whether this provider supports restricting the list of schemas to those
 with visible objects. 
 | 
void | 
clearAllCaches()
Clears all cached information in this provider that has been loaded
 from the underlying database. 
 | 
void | 
close()
Closes the Database Connection (and the supplied JDBC Connection). 
 | 
DBObjectID | 
createID(Schema schema,
        java.lang.String name,
        java.lang.String type,
        java.lang.Object id)  | 
DBObjectID | 
createID(java.lang.String dbName,
        Schema schema,
        java.lang.String name,
        java.lang.String type,
        java.lang.Object id)  | 
protected Schema | 
createSchema(java.lang.String name)  | 
boolean | 
exists(java.lang.String type,
      java.lang.String schema,
      java.lang.String name)
Checks for existance of a schema object named  
objectName. | 
protected boolean | 
exists(SystemObject obj)
Whether the specified object exists. 
 | 
protected SystemObject | 
findOrCreateObject(DBObjectLister.ObjectInfo info,
                  DBObjectCriteria criteria)
Checks the cache for an existing object and if there isn't one creates
 a new object using the registered builder and marks it for lazy
 initialization. 
 | 
protected SystemObject | 
findOrCreateObject(java.lang.String type,
                  Schema schema,
                  java.lang.String name,
                  java.lang.Object idVal)
Checks the cache for an existing object and if there isn't one creates
 a new object using the registered builder and marks it for lazy
 initialization. 
 | 
protected SystemObject | 
findOrCreateObject(java.lang.String type,
                  java.lang.String dbName,
                  Schema schema,
                  java.lang.String name,
                  java.lang.Object idVal)
Checks the cache for an existing object and if there isn't one creates
 a new object using the registered builder and marks it for lazy
 initialization. 
 | 
protected SystemObject | 
findOrCreateObject(java.lang.String type,
                  java.lang.String dbName,
                  Schema schema,
                  java.lang.String name,
                  java.lang.Object idVal,
                  java.lang.Long timestamp)
Checks the cache for an existing object and if there isn't one creates
 a new object using the registered builder and marks it for lazy
 initialization. 
 | 
protected void | 
finishCreate(SystemObject[] objects,
            SystemObject[] oldObjects)
Deprecated. 
 
Replaced by finishUpdates. 
 | 
protected void | 
finishDelete(SystemObject[] objs)
Deprecated. 
 
Replaced by finishUpdates. 
 | 
java.util.Collection<DBObjectChange> | 
finishUpdates(Difference listDiff)
Processes the given objects after the DDL has been fired for a create,
 update or delete operation. 
 | 
protected java.lang.String | 
getAliveTestStatement()
Returns a statement that, if executed succesfully, tests whether the given
 connections is live. 
 | 
java.lang.String | 
getCatalog()
Gets the catalog from the database that we are connected to. 
 | 
java.sql.Connection | 
getConnection()
Gets the JDBC connection associated with this database. 
 | 
java.sql.Connection | 
getConnection(boolean reconnect)
Gets the JDBC connection associated with this database. 
 | 
java.lang.String | 
getConnectionName()
Retrieves the name for the Connection associated with this Database in
 whichever connection store it is stored in. 
 | 
java.lang.String | 
getConnectionStore()
Retrieves the connection store the Connection associated with this
 Database is stored in. 
 | 
protected SystemObject | 
getCreatedObject(java.lang.String type,
                Schema schema,
                java.lang.String name)
Used by finishCreate() to get the object that's just been created back
 from the database so that it can be verified before returning to the
 user. 
 | 
protected java.lang.String | 
getCurrentSchemaName()
Gets the name of the current (active) schema for the underlying
 database connection. 
 | 
java.lang.String | 
getDatabaseSource(java.lang.String objectType,
                 Schema schema,
                 java.lang.String objectName)
Retrieves the source for an object in the database. 
 | 
java.lang.String | 
getDatabaseSource(java.lang.String objectType,
                 Schema schema,
                 java.lang.String objectName,
                 java.lang.String sourceType)
Retrieves the source for an object in the database. 
 | 
java.lang.String | 
getDatabaseType()
Gets the type of database. 
 | 
int | 
getDatabaseVersion()
Gets the version of the database for the api implementation. 
 | 
java.lang.String | 
getDBExceptionMessage(java.sql.SQLException sqe)
When a StatementWrapper encounters a SQLException when executing
 against the db, it calls this method with the SQLException to get a
 message for the wrapping DBSQLException that will be thrown. 
 | 
Schema | 
getDefaultSchema()
Returns the default schema for the connection or null if there isn't one. 
 | 
DatabaseDescriptor | 
getDescriptor()
Returns the DatabaseDescriptor for this provider. 
 | 
java.lang.String | 
getName()
The name of a provider is a displayable string that can be shown to the
 user to identify the provider. 
 | 
protected <T extends SystemObject>  | 
getObjectImpl(DBObjectCriteria<T> criteria)
getObject implementation for looking up a single object in the
 provider. 
 | 
java.lang.Object | 
getProviderIdentifier()
Gets the String that identifies this DBObjectProvider uniquely (within
 providers of the same type). 
 | 
java.lang.String | 
getProviderType()
Gets the String that identifies the type of DBObjectProvider this is an
 instance of. 
 | 
java.lang.String | 
getQualifiedName()
Retrieves a qualified name containing the connection store and connection
 name. 
 | 
protected java.lang.String | 
getTransactionTestQuery()  | 
java.lang.String | 
getUserName()
Default implementation calls  
queryCurrentUserName() and caches
 the result until the Connection is closed. | 
boolean | 
hasTransaction()
Tests whether there is currently a "transaction" open on the underlying
 java.sql.Connection. 
 | 
boolean | 
isClosed()
Tests whether the provider has been closed (e.g. 
 | 
boolean | 
isConnectionAlive()
Tests whether the connection underneath this Database is "alive" - i.e. 
 | 
protected boolean | 
isConnectionAlive(java.sql.Connection conn)
Implementation that checks whether the given (current) connection is alive. 
 | 
java.lang.Boolean | 
isConnectionClosed(java.sql.SQLException sqe)
This default implementation returns null unless the SQLException has a
 SQLState of "08003" - the ANSI standard for "closed connection". 
 | 
boolean | 
isObjectValid(java.lang.String objectType,
             java.lang.String schema,
             java.lang.String objectName)
Determines whether the specified database object is in a valid state. 
 | 
static boolean | 
isSQLStateNotImplemented(java.sql.SQLException sqe)
Tests whether the SQLState of the given exception is one of the
 standard jdbc states for "Not Implemented" - i.e. 
 | 
boolean | 
isUnsupportedOperation(java.sql.SQLException sqe)
Tests whether the given SQLException was thrown because a given
 operation was unsupported in the JDBC driver. 
 | 
protected boolean | 
isUsernameCaseInsensitive()
Deprecated. 
 
with no replacement. Override  
queryCurrentUserName()
 if the default logic is not sufficient to return an internal name. | 
protected java.lang.String | 
queryCatalog()
Query the underlying Connection for the current catalog. 
 | 
protected java.lang.String | 
queryCurrentSchemaName()
Queries the database for the current schema name. 
 | 
protected java.lang.String | 
queryCurrentUserName()
Queries the current user name for the underlying Connection. 
 | 
protected void | 
reconnect()  | 
protected void | 
reconnected(java.sql.Connection c)
Called when a reconnect happens to (re)initialise any member appropriately
 on the new Connection. 
 | 
protected abstract void | 
registerBuilders()
Called to request that the DBOBjectBuilders be registered. 
 | 
protected void | 
registerValidators()
By default this registers default validators for Schema, Sequences,
 Synonyms, Indexes, Constraints and Columns for the wizards to use. 
 | 
void | 
setStatement(java.sql.Statement statement)
Internal use only. 
 | 
boolean | 
supportsDebugging()
Whether this database instance supports JDWP debugging. 
 | 
void | 
testSQLStatement(java.lang.String sql)
Tests that the given SQL executes against the database. 
 | 
addObjectListener, addObjectListener, addObjectListener, addProviderListener, addProviderListener, cacheObject, canUpdate, checkCachedObject, commitTransaction, commitTransaction, convertObject, createObject, createObjectFactory, createObjectManager, createSchema, deleteObject, deleteSchema, destroyCache, ensureSystemObjectListDifference, findObject, findObject, findSchema, fireObjectsAdded, fireObjectsAdded, fireObjectsRemoved, fireObjectsRemoved, fireObjectUpdated, fireProviderClosed, fireProviderDeleted, fireProviderOpened, fireProviderReloaded, fireSchemaAdded, fireSchemaObjectUpdated, fireSchemaRemoved, fireSchemaUpdated, getBuilderForType, getCachedTimestamp, getCascadeManager, getCasePolicy, getDataType, getDDLGenerator, getDefaultSchemaName, getDefaultTemplateForType, getDescription, getDiffEngine, getExistingTimestamp, getExternalName, getExternalName, getExternalTimestamp, getExternalTimestampImpl, getIdentifierQuoteString, getInternalName, getInternalName, getLogger, getObject, getObject, getObjectFactory, getObjectManager, getOrCreateDataType, getPropertyManager, getQuotedNameCasePolicy, getSchema, getSchemaObjectExpanders, getTimestamp, getTimestamp, getUniqueName, getUniqueName, getUniqueNameTreatIndexAsSchemaObject, getValidatorForType, hasObjectPrivilege, hasPriviledge, hasSystemPrivilege, isEditable, isNewFromTemplateType, isRequestedObject, isRequestedObject, isValidName, isValidName, listObjects, listObjects, listObjects, listObjects, listObjects, listObjectsFromCache, listObjectsImpl, listObjectsImpl, listObjectsImpl, listObjectTypes, listSchemas, listSchemas, listSupportedDataTypes, loadObjectImpl, loadObjectImpl, loadObjectImpl, logEvent, markForLazyInit, markForLazyInit, normaliseType, putCachedTimestampKey, quoteIdentifier, registerBuilder, registerSchemaObjectExpander, registerType, registerValidator, removeObjectListener, removeProviderListener, removeProviderListener, resetObject, resetObject, resolveID, resolveIDImpl, resolveReferenceID, resolveUnspecifiedTypeID, resumeTimestampQueries, setDefaultTemplateForType, supportsObjectType, supportsTimestamps, supportsTimestamps, suspendTimestampQueries, uncacheObject, updateObject, updateObjects, updateObjects, updateSchema, validateName, validateName, validateObject, validateObject, validateObject, validateObject, validateObjectProperty, validateObjectProperty, validateObjectProperty, validateObjectProperty, validateSchema, validateSchema, validateUniqueName, validateUniqueNameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetIdentifierQuoteStringaddObjectListener, addObjectListener, addObjectListener, addProviderListener, addProviderListener, canCreate, canDelete, canUpdate, commitTransaction, createObject, createObjects, createSchema, deleteObject, deleteObjects, deleteSchema, getCascadeManager, getDataType, getDDLGenerator, getDefaultTemplateForType, getDescription, getDiffEngine, getExternalName, getExternalName, getInternalName, getInternalName, getObject, getObject, getObjectFactory, getObjectManager, getOrCreateDataType, getPropertyManager, getSchema, getTimestamp, getTimestamp, getUniqueName, getUniqueName, hasObjectPrivilege, hasPriviledge, hasSystemPrivilege, isEditable, isNewFromTemplateType, isValidName, isValidName, listObjects, listObjects, listObjects, listObjects, listObjects, listObjectTypes, listSchemas, listSchemas, listSupportedDataTypes, quoteIdentifier, removeObjectListener, removeProviderListener, removeProviderListener, setDefaultTemplateForType, supportsObjectType, supportsTimestamps, undeleteObject, undeleteObjects, updateObject, updateObjects, updateObjects, updateSchema, validateName, validateName, validateObject, validateObject, validateObject, validateObject, validateObjectProperty, validateObjectProperty, validateObjectProperty, validateObjectProperty, validateSchema, validateSchema, validateUniqueName, validateUniqueNameprotected AbstractDatabase(java.lang.String connStore,
                java.lang.String connName,
                java.sql.Connection conn)
connStore - the name of the connection store containing the
 connection.connName - the name for the connectionconn - the Connection to wrapprotected AbstractDatabase(java.lang.String connStore,
                java.lang.String connName,
                java.sql.Connection conn,
                java.lang.String type,
                int version)
connStore - the name of the connection store containing the
 connection.connName - the name for the connectionconn - the Connection to wraptype - the api database type for this databaseversion - the api database version for this databasepublic final java.lang.String getProviderType()
DBObjectProvidergetProviderType in interface DBObjectProviderDBObjectProvider.getProviderIdentifier(), 
DBObjectProviderFactory.findOrCreateProvider(String,Object)public final java.lang.Object getProviderIdentifier()
DBObjectProvidergetName() for a displayable String).getProviderIdentifier in interface DBObjectProviderDBObjectProvider.getProviderType(), 
DBObjectProviderFactory.findOrCreateProvider(String,Object), 
DBObjectProvider.getName()public final java.lang.String getDatabaseType()
DatabasegetDatabaseType in interface DatabaseDatabaseMetaData.getDatabaseProductName()public final int getDatabaseVersion()
DatabasegetDatabaseVersion in interface Databaseprotected void registerValidators()
protected final boolean exists(SystemObject obj)
exists(String,String,String) with the appropriate details.obj - The object being checkedprotected abstract void registerBuilders()
public final java.sql.Connection getConnection()
Database
 Code should, where possible, use one of the wrapper classes in
 oracle.javatools.db.execute to use a Connection and not need to
 directly call this method.
getConnection in interface DatabaseDatabase.getConnection(boolean)public final java.sql.Connection getConnection(boolean reconnect)
                                        throws DBException
DatabaseDatabase.isConnectionAlive().getConnection in interface Databasereconnect - whether to try and reconnect to the dbDBException - wrapping a SQLException if there is a problem
 reconnectingpublic final boolean isClosed()
AbstractDBObjectProviderisClosed in class AbstractDBObjectProviderpublic final boolean isConnectionAlive()
DatabaseNote the implementation of this is database specific - a positive can be assumed true but a negative could be incorrect.
isConnectionAlive in interface DatabaseDatabase.getConnection(boolean)protected boolean isConnectionAlive(java.sql.Connection conn)
getConnection() or similar, and
 only check the passed Connection object.
 The calling of this method assumes that if the execution is blocked waiting for a monitor lock, the block is because of the Connection being busy and therefore alive. It is therefore illegal for any implemenation of this method to try and get the monitor lock for any object other than the connection.
conn - the connection to check (will not be null).protected java.lang.String getAliveTestStatement()
Statement.execute(java.lang.String) to be a valid test (e.g. SELECT 1 FROM DUAL for
 Oracle).public java.lang.Boolean isConnectionClosed(java.sql.SQLException sqe)
null indicating that the exception cannot
 be identified. Consequently for the connection closed support to work a
 Database implementation should override this method.isConnectionClosed in interface Databasesqe - the exception to testpublic boolean hasTransaction()
DatabaseNote the implementation of this is database specific - a positive can be assumed true but a negative could be incorrect.
hasTransaction in interface Databaseprotected java.lang.String getTransactionTestQuery()
public void testSQLStatement(java.lang.String sql)
                      throws DBException
DatabasetestSQLStatement in interface Databasesql - the sql to testInvalidSQLException - if the sql doesn't execute (because the syntax
 is invalid etc).DBException - for any other error in executing the sqlpublic final java.lang.String getName()
DBObjectProvidergetProviderIdentifier().getName in interface DBObjectProviderDBObjectProvider.getProviderIdentifier()public final java.lang.String getConnectionName()
DatabasegetConnectionName in interface DatabaseDatabase.getConnectionStore(), 
Database.getQualifiedName()public final java.lang.String getConnectionStore()
DatabasegetConnectionStore in interface DatabaseDatabase.getQualifiedName()public final java.lang.String getQualifiedName()
DatabaseIf this connection has no connection store associated with it, this method will simply return the encoded connection name.
getQualifiedName in interface DatabaseDatabase.getConnectionStore(), 
Database.getConnectionName()protected void reconnect()
                  throws DBException
DBExceptionprotected void reconnected(java.sql.Connection c)
c - the connection to initialise onpublic void clearAllCaches()
AbstractDBObjectProviderclearAllCaches in class AbstractDBObjectProviderpublic void close()
Databasepublic boolean exists(java.lang.String type,
             java.lang.String schema,
             java.lang.String name)
DatabaseobjectName.public boolean isObjectValid(java.lang.String objectType,
                    java.lang.String schema,
                    java.lang.String objectName)
DatabaseisObjectValid in interface DatabaseobjectType - the type of the object.schema - the name of the schema containing the objectobjectName - the name of the objectprotected final Schema createSchema(java.lang.String name)
@Deprecated protected void finishCreate(SystemObject[] objects, SystemObject[] oldObjects) throws DBException
DBExceptionpublic java.util.Collection<DBObjectChange> finishUpdates(Difference listDiff) throws DBException
listDiff - a Difference of two SystemObject[] representing the
 original and updated object definitionsDBException - if we cannot find any of the new or updated
 objects in the databaseprotected SystemObject getCreatedObject(java.lang.String type, Schema schema, java.lang.String name) throws DBException
 By default this just calls AbstractDBObjectProvider.loadObjectImpl(DBObjectCriteria).
 It is separate from loadObjectImpl to allow subclasses to customise
 logic for matching an object that has been created, but the db has
 changed the name during the create process.
 
It is not expected that the object will already be in the cache when this method is called.
@Deprecated protected void finishDelete(SystemObject[] objs)
public java.lang.String getDatabaseSource(java.lang.String objectType,
                                 Schema schema,
                                 java.lang.String objectName)
                                   throws DBException
Databasenull.getDatabaseSource in interface DatabaseobjectType - The type of object for which the source is neededschema - The Schema containing the objectobjectName - The name of the objectDBException - if an error occurs fetching the sourcepublic java.lang.String getDatabaseSource(java.lang.String objectType,
                                 Schema schema,
                                 java.lang.String objectName,
                                 java.lang.String sourceType)
                                   throws DBException
Databasenull. This method combines spec and
 body for those source types that support both.getDatabaseSource in interface DatabaseobjectType - The type of object for which the source is neededschema - The Schema containing the objectobjectName - The name of the objectsourceType - In the case of types that have more than one source,
 the type of source required. Can be Database.SOURCE_TYPE_SPEC or
 Database.SOURCE_TYPE_BODY. If null, the default of body is selected.DBException - if an error occurs fetching the sourcepublic Schema getDefaultSchema() throws DBException
getDefaultSchema in interface DBObjectProviderDBException@Deprecated protected boolean isUsernameCaseInsensitive()
queryCurrentUserName()
 if the default logic is not sufficient to return an internal name.protected final java.lang.String getCurrentSchemaName()
                                               throws DBException
DBExceptionprotected java.lang.String queryCurrentSchemaName()
                                           throws DBException
DBExceptionpublic final java.lang.String getCatalog()
protected java.lang.String queryCatalog()
                                 throws DBException
DBExceptionpublic final java.lang.String getUserName()
queryCurrentUserName() and caches
 the result until the Connection is closed.getUserName in interface DatabaseDBObjectProvider.getDefaultSchema()protected java.lang.String queryCurrentUserName()
                                         throws DBException
DBExceptionpublic boolean supportsDebugging()
Databasefalse.supportsDebugging in interface Databasetrue if JDWP debugging is supported against this
 database, false otherwiseprotected <T extends SystemObject> T getObjectImpl(DBObjectCriteria<T> criteria) throws DBException
AbstractDBObjectProvidergetObjectImpl in class AbstractDBObjectProvidercriteria - the lookup criteriaDBExceptionpublic DatabaseDescriptor getDescriptor()
DBObjectProvidergetDescriptor in interface DBObjectProviderpublic boolean canRestrictSchemaList()
DatabasecanRestrictSchemaList in interface Databasepublic void setStatement(java.sql.Statement statement)
statement - the Statement being executedjava.lang.IllegalArgumentException - if a non-null Statement is passed and
 there is already a non-null Statement recorded against the AbstractDatabasepublic void cancelStatement()
StatementWrapper/QueryWrapperprotected final SystemObject findOrCreateObject(java.lang.String type, Schema schema, java.lang.String name, java.lang.Object idVal) throws DBException
type - the object typeschema - the owning schema (or null for a non-schema object)name - the object nameidVal - the identifier for the object in the db (or null if
 name is the identifier).DBExceptionprotected final SystemObject findOrCreateObject(java.lang.String type, java.lang.String dbName, Schema schema, java.lang.String name, java.lang.Object idVal) throws DBException
type - the object typedbName - the name of the containing database (or null for normal
 objects).schema - the owning schema (or null for a non-schema object)name - the object nameidVal - the identifier for the object in the db (or null if
 name is the identifier).DBExceptionprotected final SystemObject findOrCreateObject(java.lang.String type, java.lang.String dbName, Schema schema, java.lang.String name, java.lang.Object idVal, java.lang.Long timestamp) throws DBException
type - the object typedbName - the name of the containing database (or null for normal
 objects).schema - the owning schema (or null for a non-schema object)name - the object nameidVal - the identifier for the object in the db (or null if
 name is the identifier).timestamp - the timestamp for the object (when it was last
 modified) from the db (or null if we don't have one).DBExceptionprotected final SystemObject findOrCreateObject(DBObjectLister.ObjectInfo info, DBObjectCriteria criteria) throws DBException
info - the listed object informationcriteria - the criteria used to list the objectDBExceptionpublic final DBObjectID createID(Schema schema, java.lang.String name, java.lang.String type, java.lang.Object id)
public final DBObjectID createID(java.lang.String dbName, Schema schema, java.lang.String name, java.lang.String type, java.lang.Object id)
public java.lang.String getDBExceptionMessage(java.sql.SQLException sqe)
sqe - the encountered exceptionpublic boolean isUnsupportedOperation(java.sql.SQLException sqe)
SQLFeatureNotSupportedException or the standard sql states
 for an unsupported operation.public static boolean isSQLStateNotImplemented(java.sql.SQLException sqe)
sqe - the exception to check