Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.1.0)

E13403-02

oracle.javatools.db.ddl
Class DDLDatabase

java.lang.Object
  extended by oracle.javatools.db.AbstractDBObjectProvider
      extended by oracle.javatools.db.AbstractDatabase
          extended by oracle.javatools.db.ddl.DDLDatabase
All Implemented Interfaces:
Database, DBObjectProvider
Direct Known Subclasses:
DictionaryDatabase

public abstract class DDLDatabase
extends AbstractDatabase

Database implementation that uses a DDLGenerator to create, update and delete objects.

Since:
11

Field Summary
 
Fields inherited from class oracle.javatools.db.AbstractDatabase
SQLSTATE_NOT_IMPLEMENTED
 
Fields inherited from class oracle.javatools.db.AbstractDBObjectProvider
CASE_SENSITIVE_NAME_POLICY, EMPTY_LIST, LOWER_CASE_NAME_POLICY, MIXED_CASE_NAME_POLICY, TIMESTAMP_PROPERTY, UPPER_CASE_NAME_POLICY
 
Fields inherited from interface oracle.javatools.db.Database
FOUR_GIG, GENERIC_JDBC_DATABASE, SOURCE_TYPE_BODY, SOURCE_TYPE_SPEC, TWO_GIG
 
Fields inherited from interface oracle.javatools.db.DBObjectProvider
CREATE_PRIVILEDGE, DELETE_PRIVILEDGE, MODIFY_PRIVILEDGE, NEW_FROM_TEMPLATE_TYPE
 
Constructor Summary
protected DDLDatabase(java.lang.String connStore, java.lang.String connName, java.sql.Connection conn)
           
 
Method Summary
protected  void cacheSchema(java.lang.String name, Schema schema)
           
protected  void cacheSchema(java.lang.String name, Schema schema, boolean pin)
           
 boolean canCreate(Schema schema, boolean replace)
          Whether an attempt to create the specified schema is likely to succeed.
 boolean canCreate(SchemaObject object, boolean replace)
          Whether an attempt to create the specified object is likely to succeed.
 boolean canDelete(Schema schema, boolean cascade)
          Checks to see whether a specific schema can be deleted.
 boolean canDelete(SchemaObject obj, boolean cascade)
          Checks to see whether a specific object can be deleted.
 void close()
          Closes the Database Connection (and the supplied JDBC Connection).
 void createObjects(SchemaObject[] objects, boolean replace)
          Causes the creation of the objects described by the specified meta data.
 void createSchema(Schema schema, boolean replace)
          Causes the creation of a new Schema in the persistent storage.
 void deleteObject(SchemaObject object, boolean cascade)
          Deletes the object.
 void deleteObjects(SchemaObject[] objects, boolean cascade)
          Deletes the objects.
 void deleteSchema(Schema schema, boolean cascade)
          Deletes the schema.
protected  boolean executeDDL(DDL ddl, boolean ignoreErrors)
           
protected  Schema getCachedSchema(java.lang.String name)
           
 DDLGenerator getDDLGenerator()
          Gets the DDLGenerator for this DDLDatabase implementation.
 DiffEngine getDiffEngine()
          Returns a diff engine setup with the appropriate set of differs for object updating.
 Schema getSchema(java.lang.String name)
          Retrieves the Schema object associated with a specific name.
protected  boolean isCauseNameInUse(DBException dbe)
          Used by processCreateException to determine whether the given failure in DDL execution should be rolled back (i.e.
 Schema[] listSchemas()
          Executes a query to retrive the schemas defined by this database.
protected  boolean loadAllSchemas(boolean force)
          Loads the schemas from the database.
protected abstract  java.util.Map<java.lang.String,Schema> loadSchemasImpl()
          Implementation that should be implemented to load schemas from the database.
protected  void processCreateException(DBException dbe, SchemaObject object)
           
protected  void processDeleteException(DBException dbe, SchemaObject object)
           
protected  void registerExpanders()
           
protected  void throwUnsupportedOperation(java.lang.String msg, DBObject... objs)
           
protected  void throwUnsupportedOperation(java.lang.UnsupportedOperationException base, DBObject... objs)
           
protected  boolean uncacheSchema(java.lang.String name)
           
 void undeleteObject(SchemaObject object)
          Undeletes the object, i.e.
 void undeleteObjects(SchemaObject[] objects)
          Undeletes the objects, i.e.
 void updateObject(SchemaObject oldObject, SchemaObject newObject)
          Updates the definition of an object.
 void updateObjects(ResultSet rs, boolean replace, boolean cascade)
          Updates the definition of a set of objects.
 void updateObjects(SchemaObject[] oldObjects, SchemaObject[] newObjects)
          Updates the definition of a set of objects.
 void updateSchema(Schema oldSchema, Schema newSchema)
          Updates the definition of a Schema.
 
Methods inherited from class oracle.javatools.db.AbstractDatabase
cancelStatement, canRestrictSchemaList, createByIDImpl, createSchema, exists, exists, finishCreate, finishDelete, finishDelete, getAliveTestStatement, getConnection, getConnection, getConnectionName, getConnectionStore, getCreatedObject, getDatabaseSource, getDatabaseSource, getDefaultSchema, getDescriptor, getName, getObjectImpl, getQualifiedName, getTransactionTestQuery, hasTransaction, isConnectionAlive, isConnectionAlive, isObjectValid, isUsernameCaseInsensitive, listSchemas, reconnect, reconnected, registerBuilders, registerValidators, sqlTrace, sqlTrace, supportsDebugging
 
Methods inherited from class oracle.javatools.db.AbstractDBObjectProvider
addProviderListener, cacheObject, clearAllCaches, clearCache, convertObject, createObject, createObjectManager, createSchemaObjectImpl, destroyCache, findByID, findObject, findObject, fireObjectsAdded, fireObjectsRemoved, fireProviderClosed, fireProviderDeleted, fireProviderOpened, fireProviderReloaded, fireSchemaAdded, fireSchemaObjectUpdated, fireSchemaRemoved, fireSchemaUpdated, getBuilderForType, getCasePolicy, getDataType, getDefaultTemplateForType, getExternalName, getExternalName, getExternalTimestamp, getIdentifierQuoteString, getInternalName, getInternalName, getLogger, getObject, getObjectManager, getOrCreateDataType, getPropertyManager, getQuotedNameCasePolicy, getSchemaObjectExpanders, getTimestamp, getTimestamp, getUniqueName, getValidatorForType, hasPriviledge, isEditable, isNewFromTemplateType, isRequestedObject, isValidName, isValidName, listObjects, listObjects, listObjects, listObjects, listObjectsFromCache, listObjectsImpl, listObjectsImpl, listObjectTypes, listSupportedDataTypes, logEvent, markForLazyInit, normaliseType, quoteIdentifier, registerBuilder, registerSchemaObjectExpander, registerType, registerValidator, removeProviderListener, resetSchemaObject, schemaUpdated, setDefaultTemplateForType, supportsObjectType, supportsTimestamps, uncacheObject, unregisterBuilder, unregisterValidator, validateName, validateName, validateObject, validateObject, validateObject, validateObject, validateObjectProperty, validateObjectProperty, validateSchema, validateSchema, validateUniqueName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.javatools.db.Database
getDatabaseType, getIdentifierQuoteString, getUserName
 
Methods inherited from interface oracle.javatools.db.DBObjectProvider
addProviderListener, createObject, getDataType, getDefaultTemplateForType, getExternalName, getExternalName, getInternalName, getInternalName, getObject, getObjectManager, getOrCreateDataType, getTimestamp, getTimestamp, getUniqueName, hasPriviledge, isEditable, isNewFromTemplateType, isValidName, isValidName, listObjects, listObjects, listObjects, listObjects, listObjectTypes, listSupportedDataTypes, quoteIdentifier, removeProviderListener, setDefaultTemplateForType, supportsObjectType, validateName, validateName, validateObject, validateObject, validateObject, validateObject, validateObjectProperty, validateObjectProperty, validateSchema, validateSchema, validateUniqueName
 

Constructor Detail

DDLDatabase

protected DDLDatabase(java.lang.String connStore,
                      java.lang.String connName,
                      java.sql.Connection conn)
Method Detail

getDDLGenerator

public DDLGenerator getDDLGenerator()
Gets the DDLGenerator for this DDLDatabase implementation. This is a convinience method to wrap DatabaseDescriptor.getDDLGenerator(oracle.javatools.db.DBObjectProvider).

Overrides:
getDDLGenerator in class AbstractDatabase
Returns:
the DDLGenerator for this Database.

getDiffEngine

public DiffEngine getDiffEngine()
Description copied from interface: DBObjectProvider
Returns a diff engine setup with the appropriate set of differs for object updating.

Providers which do not support object updating should return null.

Specified by:
getDiffEngine in interface DBObjectProvider
Overrides:
getDiffEngine in class AbstractDBObjectProvider

executeDDL

protected final boolean executeDDL(DDL ddl,
                                   boolean ignoreErrors)
                            throws DBException
Throws:
DBException

throwUnsupportedOperation

protected void throwUnsupportedOperation(java.lang.UnsupportedOperationException base,
                                         DBObject... objs)
                                  throws DBException
Throws:
DBException

throwUnsupportedOperation

protected void throwUnsupportedOperation(java.lang.String msg,
                                         DBObject... objs)
                                  throws DBException
Throws:
DBException

canCreate

public final boolean canCreate(SchemaObject object,
                               boolean replace)
Description copied from interface: DBObjectProvider
Whether an attempt to create the specified object is likely to succeed.

Parameters:
object - the SchemaObject describing the object to create
replace - whether to replace an existing object. If replace is false and the object exists, canCreate must return false.
Returns:
whether the create will succeed.

canCreate

public final boolean canCreate(Schema schema,
                               boolean replace)
Description copied from interface: DBObjectProvider
Whether an attempt to create the specified schema is likely to succeed.

Parameters:
schema - the Schema describing the object to create
replace - whether to replace an existing schema. If replace is false and the schema exists, canCreate must return false.
Returns:
whether the create will succeed.

canDelete

public final boolean canDelete(Schema schema,
                               boolean cascade)
Description copied from interface: DBObjectProvider
Checks to see whether a specific schema can be deleted.

Parameters:
schema - the object to check
cascade - whether to assume a cascading delete should be used.
Returns:
whether the delete, if attempted, would succeed.

canDelete

public final boolean canDelete(SchemaObject obj,
                               boolean cascade)
Description copied from interface: DBObjectProvider
Checks to see whether a specific object can be deleted.

Parameters:
obj - the object to check
cascade - whether to assume a cascading delete should be used.
Returns:
whether the delete, if attempted, would succeed.

createSchema

public final void createSchema(Schema schema,
                               boolean replace)
                        throws DBException
Description copied from interface: DBObjectProvider
Causes the creation of a new Schema in the persistent storage.

Parameters:
schema - the schema being created
replace - whether to replace an existing schema
Throws:
DBException - if an error is encountered creating the schema

deleteSchema

public final void deleteSchema(Schema schema,
                               boolean cascade)
                        throws DBException
Description copied from interface: DBObjectProvider
Deletes the schema.

Parameters:
schema - the schema to delete
cascade - whether to delete dependent objects (i.e. all SchemaObjects contained in the Schema).
Throws:
DBException - if an error is encountered performing the delete

updateSchema

public final void updateSchema(Schema oldSchema,
                               Schema newSchema)
                        throws DBException
Description copied from interface: DBObjectProvider
Updates the definition of a Schema.

Parameters:
oldSchema - the old version of the schema
newSchema - the new version of the schema
Throws:
DBException - if the update fails

createObjects

public final void createObjects(SchemaObject[] objects,
                                boolean replace)
                         throws DBException
Description copied from interface: DBObjectProvider
Causes the creation of the objects described by the specified meta data.

Parameters:
objects - the SchemaObject[] describing the objects to create.
replace - whether to replace an existing objects. If replace is false and the object exists, createObjects will fail.
Throws:
DBException - if an error is encountered creating the objects.

processCreateException

protected void processCreateException(DBException dbe,
                                      SchemaObject object)
                               throws DBException
Throws:
DBException

isCauseNameInUse

protected boolean isCauseNameInUse(DBException dbe)
Used by processCreateException to determine whether the given failure in DDL execution should be rolled back (i.e. the objects deleted again). If this returns true (i.e. the cause is that the name is in use) then we will not rollback the attempted create.


deleteObject

public final void deleteObject(SchemaObject object,
                               boolean cascade)
                        throws DBException
Description copied from interface: DBObjectProvider
Deletes the object.

Specified by:
deleteObject in interface DBObjectProvider
Overrides:
deleteObject in class AbstractDBObjectProvider
Parameters:
object - the object to delete
cascade - whether to delete dependent objects
Throws:
DBException - if an error is encountered performing the delete

deleteObjects

public void deleteObjects(SchemaObject[] objects,
                          boolean cascade)
                   throws DBException
Description copied from interface: DBObjectProvider
Deletes the objects.

Parameters:
objects - the objects to delete
cascade - whether to delete dependent objects
Throws:
DBException - if an error is encountered performing the delete

processDeleteException

protected void processDeleteException(DBException dbe,
                                      SchemaObject object)
                               throws DBException
Throws:
DBException

undeleteObject

public final void undeleteObject(SchemaObject object)
                          throws DBException
Description copied from interface: DBObjectProvider
Undeletes the object, i.e. removes it from the recycle bin. In Oracle, only tables and indexes can be undeleted.

Parameters:
object - the object to be undeleted
Throws:
DBException - if an error is encountered performing the undelete

undeleteObjects

public final void undeleteObjects(SchemaObject[] objects)
                           throws DBException
Description copied from interface: DBObjectProvider
Undeletes the objects, i.e. removes them from the recycle bin. In Oracle, only tables and indexes can be undeleted.

Parameters:
objects - the objects to be undeleted
Throws:
DBException - if an error is encountered performing the undelete

updateObject

public final void updateObject(SchemaObject oldObject,
                               SchemaObject newObject)
                        throws DBException
Description copied from interface: DBObjectProvider
Updates the definition of an object.

Specified by:
updateObject in interface DBObjectProvider
Overrides:
updateObject in class AbstractDBObjectProvider
Parameters:
oldObject - the old version of the object
newObject - the new version of the object
Throws:
DBException - if the update fails

updateObjects

public final void updateObjects(SchemaObject[] oldObjects,
                                SchemaObject[] newObjects)
                         throws DBException
Description copied from interface: DBObjectProvider
Updates the definition of a set of objects.

Specified by:
updateObjects in interface DBObjectProvider
Overrides:
updateObjects in class AbstractDBObjectProvider
Throws:
DBException - if the update fails

updateObjects

public final void updateObjects(ResultSet rs,
                                boolean replace,
                                boolean cascade)
                         throws DBException
Description copied from interface: DBObjectProvider
Updates the definition of a set of objects. The changes required are described by the ResultSet which must have been created using the DiffEngine returned by DBObjectProvider.getDiffEngine() The 'change' maybe to create, alter, or delete objects.

Parameters:
rs - the changes described as a ResultSet - this should be a LIST ResultSet with the old objects as a() and the new objects as b().
replace - true if an existing object is to be replaced (when creating)
cascade - true if cascade delete should be used to replace an object (when deleting)
Throws:
DBException

registerExpanders

protected void registerExpanders()
Specified by:
registerExpanders in class AbstractDBObjectProvider

getSchema

public Schema getSchema(java.lang.String name)
                 throws DBException
Description copied from interface: DBObjectProvider
Retrieves the Schema object associated with a specific name.

Parameters:
name - a string containing the name of the schema
Returns:
a Schema representing the schema
Throws:
DBException - if an error is encountered getting the schema

listSchemas

public final Schema[] listSchemas()
                           throws DBException
Executes a query to retrive the schemas defined by this database.

Returns:
an array of Schema defined by this database.
Throws:
DBException
See Also:
DBObjectProvider.listSchemas(boolean)

loadAllSchemas

protected final boolean loadAllSchemas(boolean force)
                                throws DBException
Loads the schemas from the database. This will do nothing after the first call unless the boolean parameter is true. It will return true if it checks with the database, and false if nothing is actually done.

Throws:
DBException

loadSchemasImpl

protected abstract java.util.Map<java.lang.String,Schema> loadSchemasImpl()
                                                                   throws DBException
Implementation that should be implemented to load schemas from the database.

Throws:
DBException

cacheSchema

protected final void cacheSchema(java.lang.String name,
                                 Schema schema)

cacheSchema

protected final void cacheSchema(java.lang.String name,
                                 Schema schema,
                                 boolean pin)

uncacheSchema

protected final boolean uncacheSchema(java.lang.String name)

getCachedSchema

protected final Schema getCachedSchema(java.lang.String name)

close

public void close()
Description copied from interface: Database
Closes the Database Connection (and the supplied JDBC Connection).

Specified by:
close in interface Database
Overrides:
close in class AbstractDatabase

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.1.0)

E13403-02

Copyright © 1997, 2009, Oracle. All rights reserved.