public class DatabaseConnections extends java.lang.Object implements Connections
DatabaseConnectionStores| Modifier and Type | Class and Description | 
|---|---|
static class  | 
DatabaseConnections.DatabaseConnectionTester
Class that can optionally be passed to  
DatabaseConnections.DatabaseConnectionTester.testConnection(java.sql.Connection) to
 peform extra tests on the Connection before it is closed. | 
| Modifier | Constructor and Description | 
|---|---|
protected  | 
DatabaseConnections(java.lang.String storeName,
                   DatabaseContextManager.ContextWrapper contextWrapper,
                   DatabaseFactory.ConnectionCreator connCreator)
Constructs a new DatabaseConnections wrapper. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addConnection(java.lang.String connName,
             java.util.Properties props)
Creates a connection in the underlying namespace with the given name and
 properties. 
 | 
void | 
addDisconnectListener(DisconnectListener l)
Adds a listener to this store of connections to be notified of (and be able
 to veto) disconnection events. 
 | 
void | 
addListener(ConnectionsListener l)
Adds a listener to this store of connections to be notified of connection
 events. 
 | 
void | 
addListener(DatabaseConnectionsListener dcl)
Adds a listener to be notified of operations within this
 DatabaseConnections instance. 
 | 
protected void | 
closeOpenConnections()
Forces all open Connections made by this instance to be closed. 
 | 
protected void | 
closeStore()
Used by DatabaseConnectionStores when a store is removed to close the
 store down, and remove any listeners or state it is using. 
 | 
void | 
disconnect(java.lang.String connName)
Disconnect the cached JDBC connections for the given connection name,
 and closes the associated Database as well. 
 | 
boolean | 
disconnect(java.lang.String connName,
          boolean force)
Disconnect the cached JDBC connections for the given connection name, and
 closes the associated Database as well. 
 | 
java.sql.Connection | 
getConnection(java.util.Properties props)
Returns a new JDBC connection for the given connection Properties. 
 | 
java.sql.Connection | 
getConnection(java.lang.String connName)
Returns a JDBC connection for the given connection name. 
 | 
Database | 
getDatabase(java.lang.String connName)
Returns a Database for the given connection name. 
 | 
Database | 
getDatabase(java.lang.String connName,
           boolean create)
Returns a Database for the given connection name if one is already
 cached, and only creates a new one if  
create == true. | 
protected java.util.Collection<? extends DisconnectListener> | 
getDisconnectListeners()
Deprecated. 
 
use  
getListeners() | 
static DatabaseConnections | 
getInstance()
Returns the central instance of database connections for the current
 session. 
 | 
static DatabaseConnections | 
getLegacyPrivateInstance(java.net.URL url)
Creates a private DatabaseConnections instance that exclusively uses
 legacy encryption. 
 | 
protected java.util.Collection<DatabaseConnectionsListener> | 
getListeners()
Gets the listeners to this set of connections. 
 | 
static DatabaseConnections | 
getPrivateInstance(java.net.URL url)
Gets a connections instance for the given URL. 
 | 
static DatabaseConnections | 
getPrivateInstance(java.net.URL url,
                  java.lang.String key)
Returns a private instance of database connections for the given URL. 
 | 
java.util.Properties | 
getProperties(java.lang.String connName)
Returns a Properties object containing the properties for the given
 connection name. 
 | 
DatabaseProvider | 
getReferenceable(java.lang.String connName)
Returns the Referenceable for the given connection name, containing the
 details about the connection. 
 | 
java.lang.String | 
getStoreName()
Returns the name (unique identifier) for this store of database
 connections. 
 | 
java.sql.Connection | 
getUniqueConnection(java.lang.String connName)
Returns a JDBC connection for the given connection name. 
 | 
boolean | 
isCentralStore()
Convinience method to determine whether this is the central "IDE
 Connections" database store. 
 | 
java.util.Collection<java.lang.String> | 
listConnections()
Lists the names of the available database connections. 
 | 
java.util.Collection<java.lang.String> | 
listConnections(boolean oracleOnly)
Lists the available database connections, optionally limiting the
 returned names to connections to Oracle databases (not including Lite). 
 | 
java.util.Collection<java.lang.String> | 
listConnections(java.util.Properties filter)
Lists all database connections whose properties match the given filter. 
 | 
java.util.Collection<java.lang.String> | 
listConnections(java.lang.String[] subTypes)
List the available database connections that have a connection subtype
 in the given list. 
 | 
java.util.Collection<java.lang.String> | 
listOpenConnections()
Lists the names of the connections that have been opened in this store. 
 | 
boolean | 
removeConnection(java.lang.String connName)
Removes the connection with the given name. 
 | 
boolean | 
removeDisconnectListener(DisconnectListener l)
Removes a DisconnectionListener that has been previously added. 
 | 
boolean | 
removeListener(ConnectionsListener l)
Removes a connection listener that was previously added using
  
#addListener(ConnectionsListner). | 
boolean | 
removeListener(DatabaseConnectionsListener dcl)
Removed a DatabaseConnectionsListener that has been previously added. 
 | 
void | 
saveConnections()
Saves the database connection store. 
 | 
void | 
testConnection(java.util.Properties props)
Takes the given properties for a connection and attempts to connect to the
 database. 
 | 
void | 
testConnection(java.util.Properties props,
              DatabaseConnections.DatabaseConnectionTester tester)
Takes the given properties for a connection and attempts to connect to the
 database. 
 | 
boolean | 
updateConnection(java.lang.String connName,
                java.lang.String newName,
                java.util.Properties newProps)
Updates the definition of the given connection with the new set of
 properties. 
 | 
boolean | 
updateConnection(java.lang.String connName,
                java.lang.String newName,
                java.util.Properties newProps,
                boolean skipDisconnect)
Updates the definition of the given connection with the new set of
 properties. 
 | 
static void | 
useStandaloneConnectionStore()
Deprecated. 
 
with no replacement. This is configured automatically if a
 product other than JDeveloper has no jndi context wrapper set up using
 the appropriate singleton hook. 
 | 
protected DatabaseConnections(java.lang.String storeName,
                              DatabaseContextManager.ContextWrapper contextWrapper,
                              DatabaseFactory.ConnectionCreator connCreator)
storeName - the name of this connection store.contextWrapper - the wrapper for the underlying JNDI contextconnCreator - the ConnectionCreator to create new connectionsprotected void closeStore()
protected void closeOpenConnections()
public void addListener(ConnectionsListener l)
 To add connection listeners generically to any or all database connection
 stores, add a StoreProvider using the appropriate extension.xml
 hook and use the events passed to that provider to add and remove
 listeners to the DatabaseConnections store(s) required.
addListener in interface Connectionsl - the listener to addpublic boolean removeListener(ConnectionsListener l)
#addListener(ConnectionsListner).removeListener in interface Connectionsl - the listener to removeprotected java.util.Collection<DatabaseConnectionsListener> getListeners()
public void addDisconnectListener(DisconnectListener l)
 To add disconnect listeners generically to any or all database connection
 stores, add a StoreProvider using the appropriate extension.xml
 hook and use the events passed to that provider to add and remove listeners
 to the DatabaseConnections store(s) required.
addDisconnectListener in interface Connectionsl - the listener to addpublic boolean removeDisconnectListener(DisconnectListener l)
removeDisconnectListener in interface Connectionsl - the listener to removeaddDisconnectListener(DisconnectListener)public void addListener(DatabaseConnectionsListener dcl)
dcl - the listener to addpublic boolean removeListener(DatabaseConnectionsListener dcl)
dcl - the listener to removeaddListener(DatabaseConnectionsListener)@Deprecated protected java.util.Collection<? extends DisconnectListener> getDisconnectListeners()
getListeners()public final java.util.Collection<java.lang.String> listConnections()
listConnections in interface Connectionspublic final java.util.Collection<java.lang.String> listConnections(boolean oracleOnly)
oracleOnly - if true only oracle connections will be listedpublic java.util.Collection<java.lang.String> listConnections(java.lang.String[] subTypes)
subTypes - the connection subtypes to listpublic final java.util.Collection<java.lang.String> listConnections(java.util.Properties filter)
listConnections in interface Connectionsfilter - the properties that all listed connections must matchpublic java.util.Collection<java.lang.String> listOpenConnections()
public final java.sql.Connection getConnection(java.lang.String connName)
                                        throws ConnectionException
connName - the connection nameConnectionException - if the connection cannot be createdgetUniqueConnection(java.lang.String)public final java.sql.Connection getUniqueConnection(java.lang.String connName)
                                              throws ConnectionException
connName - the connection nameConnectionException - if the connection cannot be createdgetConnection(String)public final java.sql.Connection getConnection(java.util.Properties props)
                                        throws ConnectionException
props - the properties to get a Connection forConnectionException - if the connection cannot be createdpublic final Database getDatabase(java.lang.String connName) throws DBException
DBObjectProviderFactory using Database.PROVIDER_TYPE
 and the qualified connection name.
 
 Note: for a private instance
 this method will work, but using DBObjectProviderFactory directly will
 not because a private instance doesn't exist in the
 DatabaseConnectionStores.
connName - the connection nameDBException - if a connection cannot be made.DBObjectProviderFactory.findOrCreateProvider(String,Object)public final Database getDatabase(java.lang.String connName, boolean create) throws DBException
create == true.
 This wraps the usage of DBObjectProviderFactory using
 Database.PROVIDER_TYPE and the qualified connection name.
 
 Note: for a private instance
 this method will work, but using DBObjectProviderFactory directly will
 not because a private instance doesn't exist in the
 DatabaseConnectionStores.
connName - the connection name to look forcreate - whether to create a Database if one existsDBException - if a connection cannot be made or the Database fails to
 initialise.DBObjectProviderFactory.findProvider(String,Object), 
DBObjectProviderFactory.findOrCreateProvider(String,Object)public DatabaseProvider getReferenceable(java.lang.String connName) throws ConnectionException
getReferenceable in interface ConnectionsconnName - the connection nameConnectionException - if an error occurs locating the given
 connection name.public final java.util.Properties getProperties(java.lang.String connName)
                                         throws ConnectionException
getProperties in interface ConnectionsconnName - the connection nameConnectionException - if an error occurs locating the given
 connection name.public void addConnection(java.lang.String connName,
                          java.util.Properties props)
                   throws ConnectionException
addConnection in interface ConnectionsconnName - the name for the new connectionprops - the properties for the new connectionConnectionException - if the connection cannot be added (for
 example the name is already in use).public boolean removeConnection(java.lang.String connName)
                         throws ConnectionException
removeConnection in interface ConnectionsconnName - the name of the connection to removeConnectionException - if an error is encountered removing the connectionpublic boolean updateConnection(java.lang.String connName,
                                java.lang.String newName,
                                java.util.Properties newProps)
                         throws ConnectionException
updateConnection in interface ConnectionsconnName - the name of the connection as already definednewName - the new name for the connection. if null the old name is
 keptnewProps - the new Properties for the connection.ConnectionException - if there is no existing connection, if
 the new connection name exists, or if there is a problem binding the
 new connection details.public boolean updateConnection(java.lang.String connName,
                                java.lang.String newName,
                                java.util.Properties newProps,
                                boolean skipDisconnect)
                         throws ConnectionException
 Care should be taken specifying skipDisconnect as leaving an
 open Connection that doesn't match the underlying connection properties
 could cause problems.
connName - the name of the connection as already definednewName - the new name for the connection. if null the old name is
 keptnewProps - the new Properties for the connection.skipDisconnect - whether to leave any open connections and simply
 update the connection properties, if false any open Connection will
 be closed if the connection properties have changed.ConnectionException - if there is no existing connection, if
 the new connection name exists, or if there is a problem binding the
 new connection details.public final void testConnection(java.util.Properties props)
                          throws ConnectionException
testConnection in interface Connectionsprops - the properties to testConnectionException - if the test failspublic final void testConnection(java.util.Properties props,
                                 DatabaseConnections.DatabaseConnectionTester tester)
                          throws ConnectionException
props - the properties to testtester - an optional tester class that can peform extra tests
 on the Connection.ConnectionException - if the test failspublic final void disconnect(java.lang.String connName)
                      throws ConnectionException
 Any registered DisconnectListeners can veto this operation. If the
 result of the disconnect is required the use
 disconnect(String,boolean).
disconnect in interface ConnectionsconnName - the connection nameConnectionException - if an error is encountered getting or
 disconnecting the connection.public final boolean disconnect(java.lang.String connName,
                                boolean force)
                         throws ConnectionException
 Any registered DisconnectListeners can veto this operation. If the result
 of the disconnect is required the use disconnect(String,boolean).
connName - the connection to disconnectforce - whether to ignore the veto attempts of any disconnect
 listenersConnectionExceptionpublic void saveConnections()
                     throws ConnectionException
saveConnections in interface ConnectionsConnectionException - if the connection store cannot be saved
 (e.g. read only file system).public java.lang.String getStoreName()
DatabaseConnectionStorespublic boolean isCentralStore()
DatabaseConnectionStores.CENTRAL_STOREpublic static DatabaseConnections getInstance()
DatabaseConnectionStores.getCurrentStore(oracle.ide.Context)public static DatabaseConnections getPrivateInstance(java.net.URL url)
 If the url exists, and contains a valid CA connections xml file, this
 will automatically detect whether it is a legacy file, or needs a key
 (passphrase). If it needs a key, the system key will be used.
 Use getPrivateInstance(URL,String) to provide the key for
 encryption/decryption of credentials for a specific URL.
 
If the file does not exist the system key will be used to encrypt any credentials. Note there is no system key in FCP products that use a resource catalog (e.g. JDeveloper), and in that case credentials will not be saved in the returned store.
 This cannot be used on CM xml files. These must be migrated first using
 CMConnectionsReader.
url - the url for the connection instancepublic static DatabaseConnections getLegacyPrivateInstance(java.net.URL url)
url - the location of the legacy connections xml filepublic static DatabaseConnections getPrivateInstance(java.net.URL url, java.lang.String key)
If no key is provided, and the URL does not exist, the store will not support encryption and no credentials will be saved to the xml file.
If no key is provided, and the URL exists and contains passwords, the system key will be used.
url - the location of the connections xml filekey - the key/passphrase to encrypt/decrypt credentials to the
 file.@Deprecated public static void useStandaloneConnectionStore()