|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.sourceforge.esw.util.database.DBConnectionPoolManager
A Factory for the creation and access of DBConnectionPool
instances.
This is a Singleton design pattern.
The DBConnectionPoolManager is used to create and get access to
DBConnectionPool instances. Access to an
DBConnectionPool instance is provided through the
getPool methods.
A DBConnectionPool instance has a URL and, if required, a UserID
that can be used to uniquely identify the source data that the connection
represents. Some databases allow the UserID and/or Password to be specified
in the URL. Some do not require secure access, so neither the UserID or
Password is required to use a DBConnectionPool instance.
A DBConnectionPool instance does not initialize the database
driver directly, but the DBConnectionPoolManager has a method to
initialize the driver for you called initializeDriver( aDriver ).
You can also follow the JDBC standard method for registering your JDBC driver
in the Java VM using the DriverManager. You should only need to
register a unique driver once during a Java VM session.
Examples:
DBConnectionPoolManager.initializeDriver( aDriver );
DBConnectionPool pl = DBConnectionPoolManager.getInstance().getPool( getURL(),
getUserID() );
| Field Summary | |
protected java.util.HashMap |
dbPools
Contains the availiable DBConnectionPool instances. |
protected static DBConnectionPoolManager |
instance
The singleton reference. |
| Constructor Summary | |
protected |
DBConnectionPoolManager()
Creates a new DBConnectionPoolManager instance. |
| Method Summary | |
void |
addPool(DBConnectionPool aPool)
Adds the specified DBConnectionPool instance to this
DBConnectionPoolManager instance. |
static DBConnectionPoolManager |
getInstance()
Returns the singleton DBConnectionPoolManager instance. |
DBConnectionPool |
getPool(java.lang.String aURL)
Returns the pool of connections for the given JDBC URL. |
DBConnectionPool |
getPool(java.lang.String aURL,
java.lang.String aUserID)
Returns the pool of connections for the given JDBC URL and user identifier. |
static void |
initializeDriver(java.lang.String aDriver)
Initializes the named driver with the JDBC DriverManager. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.HashMap dbPools
DBConnectionPool instances.protected static DBConnectionPoolManager instance
| Constructor Detail |
protected DBConnectionPoolManager()
DBConnectionPoolManager instance.| Method Detail |
public static DBConnectionPoolManager getInstance()
DBConnectionPoolManager instance.
public DBConnectionPool getPool(java.lang.String aURL)
throws java.sql.SQLException
DBConnectionPool instance does not exist, one will be created
and returned.aURL - The URL for which to get the pool of connections.java.sql.SQLException - If an error occurs during creation of the
DBConnectionPool instance.
public DBConnectionPool getPool(java.lang.String aURL,
java.lang.String aUserID)
throws java.sql.SQLException
DBConnectionPool instance does not exist,
one will be created and returned.aURL - The URL for which to get the pool of connections.aUserID - The userID for which to get the pool of connections.java.sql.SQLException - If an error occurs during creation of the
DBConnectionPool instance.public void addPool(DBConnectionPool aPool)
DBConnectionPool instance to this
DBConnectionPoolManager instance. The
DBConnectionPool instances are keyed on their URL+UserID
combination, since that should be a unique key for each unique data source.
The added DBConnectionPool instance can be then referenced by
a call to the getPool() method with the correct values for
URL and UserID.aPool - The DBConnectionPool instance to add.
public static void initializeDriver(java.lang.String aDriver)
throws java.sql.SQLException
DriverManager.aDriver - The driver to initialize.java.sql.SQLException - If an error occurs during initialization of the
driver either because the class name is invalid, or
because the driver had a problem talking to the
database.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||