Skip navigation links
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
12c (12.2.1.1)

E67111-01

Package oracle.jdeveloper.offlinedb

Database API extension for saving database object definitions in XML files.

See: Description

Package oracle.jdeveloper.offlinedb Description

Database API extension for saving database object definitions in XML files.

Since JDeveloper 9.0.5 you have been able to store database object definitions in a Project using XML files. This support started as just Tables, and has now grown to support many database objects. It is known as the "Offline Database" (offlinedb). The reason for the name is to avoid user confusion with a live database connection (to a running database) in the database navigator.

The offlinedb is built on top of the underlying JDeveloper database metadata API which from 10.1.3 is found in the oracle.javatools.db package.

(The examples in this document contain code that does no error handling. This makes it easier to read for the purposes of this document but proper error handling should be included in real code.)

Getting Started (DBObjectProvider)

The starting point for using the oracle.javatools.db api is the DBObjectProvider interface. Once you have a DBObjectProvider (provider) you can list, create, update and delete object definitions in that provider, be it a live Database or a Project containing xml files.

An offline database exists as an XML file within a project with the extension ".offlinedb". To retrieve the DBObjectProvider for that file you use the DBOBjectProviderFactory and pass the URL in as the identifier.

  import java.net.URL;
  import oracle.javatools.db.DBObjectProviderFactory;
  import oracle.jdeveloper.offlinedb.OfflineDBObjectProvider;
...

  URL url = ...
  OfflineDBObjectProvider provider =
    (OfflineDBObjectProvider)DBObjectProviderFactory.findOrCreateProvider( url );

To list the providers in a given project, there are static methods on OfflineDBObjectProvider for searching the project's content set:

java.util.Iterator<OfflineDBObjectProvider> getProviderIterator(Project p)
java.util.List<OfflineDBObjectProvider> listDBObjectProviders(Project p)

Any database object xml file in an Offline Database should be a DBObjectNode from which you can also access the DBObjectProvider.

Examples Of Using A Provider

For examples of using a DBObjectProvider see the DBObjectProvider documentation from the core database API.

In the offlinedb specifically you can also do:

  URL url = ... // url to fred.table xml file
  Table fred = (Table)( (OfflineDBObjectProvider)provider ).getObject( url );

Letting the User Choose/Create A Provider

The ProviderWizard class provides the ability to fire create/edit/chooser dialogs for the user to manage their OfflineDBObjectProvider instances. These can be used by an extension to prompt the user.

For example the following code will prompt the user to choose (or create) a provider in the given project and return you the result:

  final OfflineDBObjectProvider provider =
    ProviderWizard.chooseProvider( project, true );

To provide this choice as part of a wizard process, the panel to use is OfflineDBChooserPanel.

Storing References

All objects in the API extend the DBObject interface which includes the method getID(). This returns a DBObjectID which is used to uniquely identify objects. The resolveID() method on DBObjectID returns the original object. All objects that reference other objects in the API (FKConstraints, Synonyms, etc) use DBObjectIDs to store the reference.

See Also:
oracle.javatools.db, OfflineDBObjectProvider
Skip navigation links
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
12c (12.2.1.1)

E67111-01

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