Oracle Personalization
REAPI_RT
v9.0.2

oracle.dmt.op.re.reapi.rt
Class DBConnectionManager

java.lang.Object
  |
  +--oracle.dmt.op.re.reapi.rt.DBConnectionManager

public class DBConnectionManager
extends Object

This class is a singleton that provides access to one or many connection pools defined in a property file. A client gets access to the single instance through the static getInstance() method and can then check out and check in connections from a pool. When the client shuts down it should call the release() method to close all open connections and do other clean-up.


Method Summary
TypeMethod
 void addPool(String poolName, String dbURL, String user, String passWd, int maxConn)
          Creates an instance of DBConnectionPool.
 void freeConnection(String name, Connection con)
          Returns a connection to the named pool.
 Connection getConnection(String name)
          Returns an open connection.
 Connection getConnection(String name, long time)
          Returns an open connection.
 int getFreeConn(String name)
           
static DBConnectionManager getInstance()
          Returns the single instance, creating one if it's the first time this method is called.
 int getOpenConn(String name)
           
 void release()
          Closes all open connections and deregisters all drivers.
 void removePool(String poolName)
          Removes an instance of DBConnectionPool.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DBConnectionManager getInstance()
Returns the single instance, creating one if it's the first time this method is called.
Returns:
DBConnectionManager the single instance

freeConnection

public void freeConnection(String name,
                           Connection con)
Returns a connection to the named pool.
Parameters:
name - the pool name as defined in the properties file
con - the connection

getConnection

public Connection getConnection(String name)
                         throws ConnectionPoolIsFullException
Returns an open connection. If none is available, and the max number of connections has not been reached, a new connection is created.
Parameters:
name - the pool name as defined in the properties file
Returns:
Connection the connection or null

getOpenConn

public int getOpenConn(String name)

getFreeConn

public int getFreeConn(String name)

getConnection

public Connection getConnection(String name,
                                long time)
                         throws ConnectionPoolIsFullException
Returns an open connection. If none is available, and the max number of connections has not been reached, a new connection is created. If the max number has been reached, waits until one is available or the specified time has elapsed.
Parameters:
name - the pool name as defined in the properties file
time - the number of milliseconds to wait
Returns:
Connection the connection or null

release

public void release()
             throws SQLException
Closes all open connections and deregisters all drivers.

addPool

public void addPool(String poolName,
                    String dbURL,
                    String user,
                    String passWd,
                    int maxConn)
Creates an instance of DBConnectionPool. A DBConnectionPool can be defined with the following attributes:
     <poolname>.dbURL       the JDBC URL for the database
     <poolname>.user        a database user (optional)
     <poolname>.password    a database user password (if user-specified)
     <poolname>.maxconn     the maximum number of connections (optional)
 
Parameters:
poolName - the name of the connection pool
dbURL - the JDBC URL for the database
user - the user name
password - the password
maxConn - the maximum number of connections allowed

removePool

public void removePool(String poolName)
Removes an instance of DBConnectionPool.
Parameters:
poolName, - the name of the connection pool

Oracle Personalization
REAPI_RT
v9.0.2