|
|||||||||
| Home >> All >> com >> lilacsoftware >> orca >> [ DBManager overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lilacsoftware.orca.DBManager
Class DBConnectionManager

java.lang.Objectcom.lilacsoftware.orca.DBManager.DBConnectionManager
- public class DBConnectionManager
- extends java.lang.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.
| Nested Class Summary | |
(package private) class |
DBConnectionManager.DBConnectionPool
This inner class represents a connection pool. |
| Field Summary | |
private static int |
clients
|
private java.util.Vector |
drivers
|
private static DBConnectionManager |
instance
|
private java.io.PrintWriter |
log
|
private java.util.Hashtable |
pools
|
| Constructor Summary | |
private |
DBConnectionManager()
A private constructor since this is a Singleton |
| Method Summary | |
private void |
createPools(java.util.Properties props)
Creates instances of DBConnectionPool based on the properties. |
protected void |
freeConnection(java.sql.Connection con)
Returns a connection to the pool name by the app prop dbPool. |
protected void |
freeConnection(java.lang.String name,
java.sql.Connection con)
Returns a connection to the named pool. |
protected java.sql.Connection |
getConnection()
Returns an open connection. |
protected java.sql.Connection |
getConnection(long time)
Returns an open connection. |
protected java.sql.Connection |
getConnection(java.lang.String name)
Returns an open connection. |
protected java.sql.Connection |
getConnection(java.lang.String name,
long time)
Returns an open connection. |
protected static DBConnectionManager |
getInstance()
Returns the single instance, creating one if it's the first time this method is called. |
private void |
init()
Loads properties and initializes the instance with its values. |
private void |
loadDrivers(java.util.Properties props)
Loads and registers all JDBC drivers. |
private void |
log(java.lang.String msg)
Writes a message to the log file. |
private void |
log(java.lang.Throwable e,
java.lang.String msg)
Writes a message with an Exception to the log file. |
protected void |
release()
Closes all open connections and deregisters all drivers. |
(package private) void |
trace(int level,
java.lang.String msg1,
java.lang.String msg2)
Sends traces to Debug. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
instance
private static DBConnectionManager instance
clients
private static int clients
drivers
private java.util.Vector drivers
log
private java.io.PrintWriter log
pools
private java.util.Hashtable pools
| Constructor Detail |
DBConnectionManager
private DBConnectionManager()
- A private constructor since this is a Singleton
| Method Detail |
getInstance
protected static DBConnectionManager getInstance()
- Returns the single instance, creating one if it's the
first time this method is called.
freeConnection
protected void freeConnection(java.lang.String name, java.sql.Connection con)
- Returns a connection to the named pool.
freeConnection
protected void freeConnection(java.sql.Connection con)
- Returns a connection to the pool name by the app prop dbPool.
getConnection
protected java.sql.Connection getConnection(long time)
- Returns an open connection. If no one is available, and the max
number of connections has not been reached, a new connection is
created. Uses dbPool app property as pool choice.
If the max number has been reached, waits until one
is available or the specified time has elapsed.
getConnection
protected java.sql.Connection getConnection()
- Returns an open connection. If no one is available, and the max
number of connections has not been reached, a new connection is
created. Uses dbPool app property as pool choice
getConnection
protected java.sql.Connection getConnection(java.lang.String name)
- Returns an open connection. If no one is available, and the max
number of connections has not been reached, a new connection is
created.
getConnection
protected java.sql.Connection getConnection(java.lang.String name, long time)
- Returns an open connection. If no one 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.
release
protected void release()
- Closes all open connections and deregisters all drivers.
createPools
private void createPools(java.util.Properties props)
- Creates instances of DBConnectionPool based on the properties.
A DBConnectionPool can be defined with the following properties:
<poolname>.url The JDBC URL for the database <poolname>.user A database user (optional) <poolname>.password A database user password (if user specified) <poolname>.maxconn The maximal number of connections (optional)
init
private void init()
- Loads properties and initializes the instance with its values.
loadDrivers
private void loadDrivers(java.util.Properties props)
- Loads and registers all JDBC drivers. This is done by the
DBConnectionManager, as opposed to the DBConnectionPool,
since many pools may share the same driver.
log
private void log(java.lang.String msg)
- Writes a message to the log file.
log
private void log(java.lang.Throwable e, java.lang.String msg)
- Writes a message with an Exception to the log file.
trace
void trace(int level,
java.lang.String msg1,
java.lang.String msg2)
- Sends traces to Debug.
|
|||||||||
| Home >> All >> com >> lilacsoftware >> orca >> [ DBManager overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lilacsoftware.orca.DBManager.DBConnectionManager