Extension SDK

oracle.jdeveloper.cm
Class ConnectionManager

java.lang.Object
  extended byoracle.jdeveloper.cm.ConnectionManager

public final class ConnectionManager
extends java.lang.Object

ConnectionManager is responsible for creating and managing connections to data sources such as Oracle8i/9i, Oracle8i Lite, JDBC-ODBC, Vanilla JDBC, FTP, any any others)

The connection information is stored in a file which is read by the ConnectionStore associated with the ConnectionManager instance. By default, this information is stored in connections.properties. The JDeveloper IDE automatically creates this file as part of the deployment process. Upon request, ConnectionManager reads the information from the properties file in order to instantiate a connection.

If configured to do so by information stored in the properties file, ConnectionManager will prompt the user for username, password, or other necessary connection information. This prevents security from being compromised by removing the need to store sensitive information externally.

ConnectionManager is designed to be a singleton class so as to be easy to use and support. However, under certain circumstances (especially with Applets), users may desire to manage their own instance of ConnectionManager. In these cases, the JDeveloper IDE may not be able to assist in automatic code generation.


 

Using ConnectionManager in an Application

Using ConnectionManager is a fairly straightforward exercise. There are only a few things the developer needs to be aware of.

First, and probably most importantly, it is imperative that some user object (usually the application itself) hold on to an instance of ConnectionManager for the duration of the application. This prevents ConnectionManager from being inadvertantly garbage collected.

A related issue which greatly affects performance is excessive use of getConnection followed very shortly by close. While it is possible to use these two methods everywhere the developer desires to use a connection, it can severely impact performance. If a connections reference count goes to zero, that connection is shut down. Any subsequent attempt to use that same named connection will result in a time-consuming login operation. Thus, the developer must take care to manage the lifecycle of open connections appropriately.

Using ConnectionManager in an Applet.

For the Applet developer, there are a few other issues to take heed of.

Applets loaded from the same network source can share the same namespace. This means that different applets can share the same ConnectionManager, and therefore, access to the same connections. This is not considered to be a security compromise for the following reasons:

However, for developers who would like to insulate themselves further from possible security risks, ConnectionManager allows developers to manage their own instance(s) of ConnectionManager.

Altering ConnectionManager's prompting behavior.

By default, ConnectionManager will always prompt for username, password, and role (only applicable for IIOP connections). However, this behavior may not always be appropriate. Furthermore, appropriate behavior may change from connection to connection. Therefore, ConnectionManager allows it behavior in this area to be customized.

Using the setDefaultPrompter method, users are able to customize not only the UI used by default to prompt for connection information, but also whether, by default, to prompt for information at all. The getConnection methods also allow for customization of prompting behavior. Examples of these can be found below.

ConnectionManager allows the developer

Examples