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


Package oracle.javatools.db

Contains a metadata API for describing database objects, and retrieving them from a provider of database objects - for example a database.


Interface Summary
BinaryObject Interface for an object from the db that has a binary representation (e.g.
ChildDBObject Interface that any DBObject should implement if it can exist as the child of another DBObject.
ColumnConstraintReferenceID Deprecated.
Database Provides a interface for accessing a database.
DBObject Base interface for Database Objects.
DBObjectBuilder<T extends DBObject> The DBObjectBuilder interface provides a mechanism for constructing new instances representing database objects.
DBObjectFilter<T extends DBObject> Interface to use when searching DBObjects for a particular object, or objects.
DBObjectID Interface representing an immutable object ID for a DBObject.
DBObjectProvider The DBObjectProvider interface provides clients with access to database objects.
DBObjectProviderFactory.Listener Listener interface that can be registered against this factory to be notified of provider create and uncache events.
DBObjectProviderListener Listener for attaching to a DBObjectProvider to be notified of changes to the provider.
DBObjectValidator<T extends DBObject> A DBObjectValidator is responsible for validating a specific type of DBObject instance.
DBReferenceID Deprecated.
DDLGenerator Deprecated. - replaced by DDLGenerator
DeclarativePlSql A DeclarativePlSql object is a pl/sql object in the database that can be resprented declaratively - for example the parameters, return type, etc of a method can be set as properties (instead of being simply a block of code).
JdbcDatabase Implementation of the Database interface for JDBC Databases.
ProviderUsage Should be implemented by any DBObject that requires a DBObjectProvider to be set in order to operate.
SchemaObject A SchemaObject represents a database object that can exist within the context of a schema.
SchemaObjectExpander A SchemaObjectExpander can be registered against a DBObjectProvider, and will then be called to "expand" any object created or updated in that provider.
SchemaObjectListener Deprecated. replaced by DBObjectListener
SourceObject Any object in the database that can contain a block of source code - for example java or PL/SQL.
SystemObject A system object is available at the DBObjectProvider level through the list and get methods, and can be created/updated/deleted.
TemplateExpander.Initialiser The template mechanism can be extended by Initialiser objects that can perform extra template work on newly templated objects before they're commited to the provider.

Class Summary
AbstractBuildableObject Provides methods for lazy loading and building AbstractDBObjects.
AbstractChildDBObject Extension of DBObject used by child object in the API.
AbstractDatabase Base implementation of the Database interface.
AbstractDBObject Provides an abstract implementation of the DBObject interface.
AbstractDBObjectBuilder<T extends AbstractBuildableObject> Abstract implementation of DBObjectbuilder that provides core support for component building of objects.
AbstractDBObjectID Abstract implementation of DBObjectID for subclassing by DBObjectID implementations.
AbstractDBObjectProvider Provides a base implementation of the DBObjectProvider interface.
AbstractSchemaObject Provides a base implementation of the SchemaObject interface.
BaseObjectID Base DBObjectID implementation that stores the object name and (optionally) schema name of the object.
CascadeManager Provides facilities for listing references between DBObjects in a DBObjectProvider, and provides cascade logic for cascading delete of an object.
CheckConstraint A CheckConstraint constrains a table or view based on a conditional expression.
Column Model of a database column.
ColumnConstraint Abstract model of a Constraint that constrains Columns in the database.
Constraint A Constraint represents a constraint on a table or view.
ConstraintID Deprecated.
DatabaseDescriptor<T extends Database> Interface used to describe the behaviour of a Database.
DatabaseFactory DatabaseFactory is a DBObjectProviderFactory.Creator implementation.
DatabaseFactory.ConnectionCreator A connection creator should be registered for each connection store that exists.
DatabaseFactory.DatabaseCreator Plugin to the DatabaseFactory for creating Databases and DatabaseDescriptors.
DBCore The DBCore serves two purposes: Allows registration of classes in db-api-impl to core api Provides a single point through which our singletons are registered
DBLog Log utilities for the core database functionality.
DBObjectChange A DBObjectChange is used to notify of changes to a DBObject.
DBObjectCriteria<T extends SystemObject> A DBObjectCriteria is used when listing objects from a DBObjectProvider to specify the criteria by which the list should be restricted.
DBObjectFactory Factory to control the creation of SchemaObjects and ChildDBObjects which may be based on templates and/or have the initial values of properties defined by PropertyInitializers.
DBObjectFilter.IDFilter<T extends DBObject> DBObjectFilter implementation that accepts objects with a given ID, optionally performing a strict comparison.
DBObjectIterator A class for iterating over owned object lists.
DBObjectListener A DBObjectListener can be registered against any ListenableObject to be identified about changes to that DBObject.
DBObjectProviderAdapter Adapter for a class to extend and implement DBObjectProviderListeners without implementing all the methods.
DBObjectProviderFactory Factory class for creating DBObjectProviders.
DBObjectProviderFactory.Creator Factory creator class used to create provider instances when there isn't one already in the cache.
DBUtil Utility class associated with the DB package.
Ddl Class for the DDL to create an object.
FKConstraint A FKConstraint represents a Foreign Key Constraint.
Function Model of a pl/sql function.
GlobalSettings Class for api settings that govern the behaviour of the api at a global level.
IdentifierBasedID The representation of an Object ID for an object in a provider that can be uniquely identified by an identifier (other than name).
IDPolicy When a DBObject is copied, the copy can optionally use an IDPolicy.
IDPolicy.DefaultIDPolicy IDPolicy that creates a TemporaryObjectID that does NOT point back to the original object for every object that has an ID.
IDPolicy.SameIDPolicy IDPolicy that simply copies the objects ID to the copy.
IDPolicy.TemporaryIDPolicy IDPolicy that creates a TemporaryObjectID for every object that has the original object set.
Index Model of a database index.
Java Abstract SchemaObject implementation for the different Java objects available in a database.
JavaClass Model of a Java Class.
JavaResource Model of a Java Resource object.
JavaSource Model of a Java Source object.
NameBasedID ID implementation that is name based.
Package Model of a PL/SQL package in the database.
PKConstraint A PKConstraint represents a Primary Key constraint.
PlSql Abstract implementation of SchemaObject for all PL/SQL objects that belong in a Schema to extend.
PlSqlAttribute Model of a PL/SQL attribute.
PlSqlMethod Model of a method in a PL/SQL object.
PlSqlParameter Model of a parameter to a PL/SQL subprogram like a function or the method of an object type.
PlSqlSubprogram Abstract implementation of PlSql for objects that are a simple subprogram (e.g.
Procedure Model of a pl/sql procedure.
ReferenceID ID implementation used for a reference property - i.e.
Relation A Relation represents the basic entity of a relational database.
Schema Model of a database schema.
SchemaObjectIterator An Iterator over all the SchemaObjects in a provider, or set of providers.
SchemaObjectManager This class is for internal use only.
Sequence Model of a database sequence.
SpecPlSql Extension of PlSql for objects that have a spec and body.
Synonym Model of a database synonym.
Table Model of a database table.
Tablespace Model of a database schema.
TemplateExpander An expander of schema objects that provides the Template support for a DBObjectProvider.
TemporaryObjectID Implementation of the DBObjectID interface for objects that only exist in memory.
Trigger Model of a database Trigger.
UniqueConstraint A UniqueConstraint prohibits multiple rows from having the same value in the same column or combination of columns but allows some values to be null.
View Represents a database View.
ViewColumn Custom Column for Views to use when they have a DeclarativeSQLQuery.

Enum Summary
DBCore.Mode The mode for the API - either command line, headless or full ide.
DBUtil.IDQuery When querying for reference IDs of an object this enum is used to define whether to query for different kinds of reference.
Index.IndexType Index type
Table.TableType Different types of Table supported in the API.
Tablespace.TablespaceType Different types of Tablespace supported in the API.
Trigger.BaseType Base type for the Trigger (i.e.
Trigger.Timing Timing of a trigger - at what point relative to the trigger event the trigger's code will be executed.

Exception Summary
CancelledException This exception is thrown if a query to the database is cancelled mid-execution by an action of the user/api.
CascadeManager.NoCascadeRequiredException Exception thrown when a cascade is requested for an object that has no referers.
CascadeRequiredException Subclass of DBException that is thrown when an attempt to delete or update an object is made when there are dependent objects in the given DBObjectProvider.
DBException An Exception that is thrown by a DB model operation.
DBSQLException DBException subclass that is thrown when a SQLException is encountered while talking to the database.
InvalidNameException ValidationException thrown when an object's name is invalid.
MissingProviderException Thrown if you attempt to resolve the ID when the provider has not been set.
MissingValidatorException Indicates that the validation of the database object failed because no DBObjectValidator was registered to handle the validation.
NameInUseException ValidationException thrown when a name is already in use.
ValidationException Indicates that the validation of the database object failed.

Package oracle.javatools.db Description

Contains a metadata API for describing database objects, and retrieving them from a provider of database objects - for example a database. Facilities are provided for creating metadata objects from an existing database connection, as well as for generating SQL to create new objects based on in memory or offline-persisted metadata.

Code Examples

Using a DBObjectProvider (provider)

Get a specific Schema

  Schema mySchema = provider.getSchema( "MYSCHEMA" );

Listing available Tables of a Schema

   String[] tabNames = provider.listObjects( Table.TYPE, mySchema );

Listing table beginning with 'A' in a Schema

   String[] tabNames = provider.listObjects( Table.TYPE, mySchema, 'A%' );

Get All Tables and Views in a Schema

   SchemaObject[] tabsAndViews = provider.listObjects(
                                   new String[]{ Table.TYPE, View.TYPE },
                                   mySchema );

Getting a Specific Object

   Table fred = (Table)provider.getObject( Table.TYPE, mySchema, "EMP" );

Updating Objects

Add a Column to a Table

  Table fred = (Table)provider.getObject( Table.TYPE, mySchema, "FRED" );

// make a fresh copy of fred and setup temporary ids
  Table newFred = fred.copyTo( null, true );

// add a new column
  Column col = new Column( "NEW_COL" );
  DataType dt = provider.getDataType( "NUMBER" );
  col.setDataTypeUsage( dt.createDefaultUsage() );
  col.setDefault( new Integer( 4 ) );
  newFred.addColumn( col );

// update the provider
  provider.updateObject( fred, newFred );

Listening for Updates

The database API has its own event/listener model. This is used to listen for new/deleted schemas, new/delete objects and changes to existing objects. The message are all concerned with a SchemaObject not a DBObject (the distinction being a SchemaObject is a "top level" object such as a Table or View, a DBObject that isn't a SchemaObject is a child object such as a Column. Notifications of updates to a Column will come through listening to the owning Table.)

New or Deleted Objects

Attach an oracle.javatools.db.DBObjectProviderListener to your provider.

Changes to an Existing Object

Attach a oracle.javatools.db.SchemaObjectListener to the given object.

  Table fred = (Table)provider.getObject( Table.TYPE, mySchema, "FRED" );
  fred.addObjectListener( myListener );

then when a the new column is added to fred by the above code the listener's update method is called:

  public void schemaObjectUpdated(DBObjectChange change)
{ DBObject changed = change.getDBObject(); if( change.hasNameChanged() ) { // the table has change named ... we must update our own information. } for( final obj : change.getOwnedObjectsAdded() ) { Object obj =; if( obj instanceof Column ) { String name = ( (Column)obj ).getName(); // name is "NEW_COL"!! } } }

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


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