Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

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.

See:
          Description

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 Deprecated. - moved to DBObjectProviderListener
DBObjectValidator<T extends DBObject> A DBObjectValidator is responsible for validating a specific type of DBObject instance.
DBReferenceID Deprecated.
DeclarativePlSql Deprecated. use PlSqlSubProgram instead
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.
AbstractSystemObject Abstract superclass for all SystemObject implementations.
AutoExtendProperties Model of properties for auto extend behavior used by Tablespaces
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.ConnectionCreatorFactory Provide ConnectionCreatorFactory implementations to provide ConnectionCreators for different stores in the product.
DatabaseFactory.DatabaseCreator Plugin to the DatabaseFactory for creating Databases and DatabaseDescriptors.
DBCore The DBCore serves two purposes: Allows registration of classes and implemetations from downstream extensions with the api. Provides a single point through which our singletons are registered
DBLog Log utilities for the core database functionality.
DBObjectChange Deprecated. - moved to oracle.javatools.db.event.DBObjectChange
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 Deprecated. - replaced with oracle.javatools.db.event.DBObjectListener
DBObjectLister Plugin to DBObjectProvider to allow objects to be listed.
DBObjectLister.ObjectInfo Encapsulates the information required about a listed object.
DBObjectProviderAdapter Deprecated. - moved to DBObjectProviderListener
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.
FileSpecification Model of File Specification properties.
FKConstraint A FKConstraint represents a Foreign Key Constraint.
Function Deprecated. use Function instead
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 Deprecated. use Package instead
PKConstraint A PKConstraint represents a Primary Key constraint.
PlSql Deprecated. use SourceObject instead
PlSqlAttribute Deprecated. use PlSqlAttribute instead
PlSqlMethod Deprecated. use PlSqlMethod instead
PlSqlParameter Deprecated. use PlSqlParameter instead
PlSqlSubprogram Deprecated. use PlSqlSubProgram instead
Procedure Deprecated. use Procedure instead
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 Deprecated. use PlSqlSchemaObjectSpec instead
Synonym Model of a database synonym.
Table Model of a database table.
Tablespace Model of a Tablespace in a database.
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 Deprecated. use Trigger instead
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 Deprecated. just use a simple Column instead
 

Enum Summary
Constraint.DeferrableState  
DBUtil.IDQuery When querying for reference IDs of an object this enum is used to define whether to query for different kinds of reference.
FileSpecification.FileStatus  
Index.IndexType Index type
PlSqlMethod.CallSpecLanguage  
PlSqlMethod.MethodType  
PlSqlParameter.Mode  
Table.TableType Different types of Table supported in the API.
Tablespace.FileType  
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.
 

Annotation Types Summary
AbstractDBObjectBuilder.PropertyBuilder Annotation to mark methods that build components (properties) of a given object within this builder.
 

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 = newKids.next(); if( obj instanceof Column ) { String name = ( (Column)obj ).getName(); // name is "NEW_COL"!! } } }


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

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