Skip navigation links

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

E13403-10


oracle.javatools.db
Class DatabaseFactory

java.lang.Object
  extended by oracle.javatools.db.DBObjectProviderFactory.Creator
      extended by oracle.javatools.db.DatabaseFactory


public final class DatabaseFactory
extends DBObjectProviderFactory.Creator

DatabaseFactory is a DBObjectProviderFactory.Creator implementation. It provides an extra ability to create new Connections for a given connection name. This provision requires a DatabaseFactory plugin that supports such an operation, by default the API does not contain one. The JDeveloper connection architecture provides such functionality and if used with jdeveloper this functionality will be available.

It is unlikely that the DatabaseFactory would be needed in the product. For the vast majority of cases, the oracle.jdeveloper.db.DatabaseConnections API (and associated classes) should be used.

Since:
10.1.3
See Also:
Database, DBObjectProviderFactory

Nested Class Summary
static class DatabaseFactory.ConnectionCreator
          A connection creator should be registered for each connection store that exists.
static class DatabaseFactory.DatabaseCreator
          Plugin to the DatabaseFactory for creating Databases and DatabaseDescriptors.

 

Method Summary
static java.sql.Connection createConnection(Database db)
          This will return a new Connection for the given database if possible.
static Database createDatabase(java.lang.String connName, DatabaseFactory.ConnectionCreator factory)
          Creates a Database using the given ConnectionCreator to create a connection for the given connection name.
protected  DBObjectProvider createProviderImpl(java.lang.Object identifier)
          Creates a provider for the given identifier if that identifier is a valid Database identifier.
static Database createStandaloneDatabase(java.lang.String name, java.sql.Connection conn)
          Creates a standalone Database for the given Connection.
static
<T extends DatabaseFactory.ConnectionCreator>
T
findConnectionCreator(java.lang.Class<T> ccc)
          Looks for a registered connection creator of the given class.
static DatabaseFactory.ConnectionCreator findConnectionCreator(Database db)
          Finds the connection creator (if one exists) that is responsible for this database instance.
static Database findOrCreateDatabase(java.lang.String name, java.sql.Connection conn)
          Deprecated. - use createStandaloneDatabase(java.lang.String, java.sql.Connection) to create a Database for an isolated connection. If a Database is required for a given connection name in the product use the appropriate connection store (e.g. Application Connections, or central IDE Connections).
protected  DBObjectProvider findProvider(java.lang.Object identifier)
           
static java.util.Collection<java.lang.Class<? extends Database>> getClasses()
          Gets the supported Database implementations from the API.
static DatabaseDescriptor getDatabaseDescriptor(java.lang.Class providerClass)
          Returns a DatabaseDescriptor for the given provider class.
static DatabaseDescriptor getDatabaseDescriptor(Database db)
          Returns a DatabaseDescriptor for the given database.
static java.lang.String getDatabaseName(java.lang.Class<? extends Database> dbClz)
          Gets a translated string that describes the given database class to the nearest supported version.
protected  java.lang.String getIdentifier(DBObjectProvider provider)
          Returns an identifier for the given provider that is used when notifying listeners of provider events.
static void registerConnectionCreator(DatabaseFactory.ConnectionCreator cc)
          Registers a Connection creator that can duplicate connections for the Databases provided by the factory.
static void registerDatabaseCreator(DatabaseFactory.DatabaseCreator dc)
          Registers a Connection creator that can identify and create Databases and DatabaseDescriptors for the factory.
protected  DBObjectProvider uncacheProvider(java.lang.Object identifier)
           

 

Methods inherited from class oracle.javatools.db.DBObjectProviderFactory.Creator
fireProviderDeleted

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

getIdentifier

protected java.lang.String getIdentifier(DBObjectProvider provider)
Description copied from class: DBObjectProviderFactory.Creator
Returns an identifier for the given provider that is used when notifying listeners of provider events. This is also the expected identifier used in DBObjectProviderFactory.Creator.findProvider(java.lang.Object) etc.
Specified by:
getIdentifier in class DBObjectProviderFactory.Creator
Returns:
null if the provider isn't associated with this Creator implementation.

createProviderImpl

protected final DBObjectProvider createProviderImpl(java.lang.Object identifier)
                                             throws DBException
Creates a provider for the given identifier if that identifier is a valid Database identifier.
Specified by:
createProviderImpl in class DBObjectProviderFactory.Creator
Throws:
DBException

createDatabase

public static Database createDatabase(java.lang.String connName,
                                      DatabaseFactory.ConnectionCreator factory)
                               throws DBException
Creates a Database using the given ConnectionCreator to create a connection for the given connection name. If the ConnectionCreator can't create a connection for the given name null is returned. This does not check any cache for an existing connection or Database, use with care.
Throws:
DBException

findProvider

protected DBObjectProvider findProvider(java.lang.Object identifier)
Overrides:
findProvider in class DBObjectProviderFactory.Creator

uncacheProvider

protected DBObjectProvider uncacheProvider(java.lang.Object identifier)
Overrides:
uncacheProvider in class DBObjectProviderFactory.Creator

findOrCreateDatabase

@Deprecated
public static final Database findOrCreateDatabase(java.lang.String name,
                                                             java.sql.Connection conn)
                                           throws DBException
Deprecated. - use createStandaloneDatabase(java.lang.String, java.sql.Connection) to create a Database for an isolated connection. If a Database is required for a given connection name in the product use the appropriate connection store (e.g. Application Connections, or central IDE Connections).
Throws:
DBException

createStandaloneDatabase

public static final Database createStandaloneDatabase(java.lang.String name,
                                                      java.sql.Connection conn)
                                               throws DBException
Creates a standalone Database for the given Connection. This should only be used in testing a Connection. In the product, Database instances are cached for named connections so that their object caches can be shared. Creating a standalone Database impementation can therefore be slower.
Parameters:
name - the name to give the Database
conn - the Connection to a database
Returns:
a Database implementation appropriate to the given Connection
Throws:
DBException

getDatabaseDescriptor

public static final DatabaseDescriptor getDatabaseDescriptor(java.lang.Class providerClass)
Returns a DatabaseDescriptor for the given provider class. Will return null if no DatabaseDescriptor can be found for the given provider class.

getDatabaseDescriptor

public static final DatabaseDescriptor getDatabaseDescriptor(Database db)
Returns a DatabaseDescriptor for the given database. Will return null if no DatabaseDescriptor can be found for the given database.

registerConnectionCreator

public static final void registerConnectionCreator(DatabaseFactory.ConnectionCreator cc)
Registers a Connection creator that can duplicate connections for the Databases provided by the factory.

registerDatabaseCreator

public static final void registerDatabaseCreator(DatabaseFactory.DatabaseCreator dc)
Registers a Connection creator that can identify and create Databases and DatabaseDescriptors for the factory.

findConnectionCreator

public static final <T extends DatabaseFactory.ConnectionCreator> T findConnectionCreator(java.lang.Class<T> ccc)
Looks for a registered connection creator of the given class. If a match is found it is returned. The match must be perfect, subclasses will not match.
Parameters:
ccc - the ConnectionCreator subclass to look for
Returns:
a registered instance of the class if there is one

findConnectionCreator

public static final DatabaseFactory.ConnectionCreator findConnectionCreator(Database db)
Finds the connection creator (if one exists) that is responsible for this database instance.

createConnection

public static final java.sql.Connection createConnection(Database db)
                                                  throws DBException
This will return a new Connection for the given database if possible. A suitable factory must be registered that can perform such an operation, if one is not present (this will be the case if using the api in standalone mode) the Database's existing connection will be returned.

This method is designed to create a duplicate Connection - the Database must have been setup with a Connection in the first place.

Throws:
DBException

getClasses

public static java.util.Collection<java.lang.Class<? extends Database>> getClasses()
Gets the supported Database implementations from the API. Although there are more Database implementations, this list is those that can be presented to a user as supported options.
Returns:
a collection of Database implementations we support.
See Also:
getDatabaseName(java.lang.Class )

getDatabaseName

public static java.lang.String getDatabaseName(java.lang.Class<? extends Database> dbClz)
Gets a translated string that describes the given database class to the nearest supported version. If no supported version is available, this will return "Generic JDBC Database" - i.e. we assume that there is no better support.
Returns:
a name for the given type (and version) of database.

Skip navigation links

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

E13403-10


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