|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.torque.pool.ConnectionPool
This class implements a simple connection pooling scheme.
Nested Class Summary | |
protected class |
ConnectionPool.Monitor
Deprecated. This inner class monitors the PoolBrokerService . |
Field Summary | |
private long |
connectionWaitTimeout
Deprecated. Amount of time a thread asking the pool for a cached connection will wait before timing out and throwing an error. |
private javax.sql.ConnectionPoolDataSource |
cpds
Deprecated. The ConnectionPoolDataSource |
static int |
DEFAULT_CONNECTION_WAIT_TIMEOUT
Deprecated. Default Connect Wait Timeout: 10 Seconds |
static int |
DEFAULT_EXPIRY_TIME
Deprecated. Default Expiry Time for a pool: 1 hour |
static int |
DEFAULT_MAX_CONNECTIONS
Deprecated. Default maximum Number of connections from this pool: One |
private long |
expiryTime
Deprecated. The amount of time in milliseconds that a connection will be pooled. |
private static org.apache.commons.logging.Log |
log
Deprecated. The logging logger. |
private int |
logInterval
Deprecated. Interval (in seconds) that the monitor thread reports the pool state |
private int |
maxConnections
Deprecated. The maximum number of database connections that can be created. |
private ConnectionPool.Monitor |
monitor
Deprecated. Monitor thread reporting the pool state |
private java.lang.String |
password
Deprecated. The password for this pool. |
private java.util.Stack |
pool
Deprecated. Pool containing database connections. |
private java.util.Map |
timeStamps
Deprecated. Keep track of when connections were created. |
private int |
totalConnections
Deprecated. The current number of database connections that have been created. |
private java.lang.String |
url
Deprecated. The url for this pool. |
private java.lang.String |
username
Deprecated. The user name for this pool. |
private int |
waitCount
Deprecated. Counter that keeps track of the number of threads that are in the wait state, waiting to aquire a connection. |
Constructor Summary | |
(package private) |
ConnectionPool(javax.sql.ConnectionPoolDataSource cpds,
java.lang.String username,
java.lang.String password,
int maxConnections,
int expiryTime,
int connectionWaitTimeout,
int logInterval)
Deprecated. Creates a ConnectionPool with the default
attributes. |
Method Summary | |
private void |
closePooledConnection(javax.sql.PooledConnection pcon)
Deprecated. |
void |
connectionClosed(javax.sql.ConnectionEvent event)
Deprecated. This will be called if the Connection returned by the getConnection method came from a PooledConnection, and the user calls the close() method of this connection object. |
void |
connectionErrorOccurred(javax.sql.ConnectionEvent event)
Deprecated. If a fatal error occurs, close the underlying physical connection so as not to be returned in the future |
(package private) void |
decrementConnections()
Deprecated. Decreases the count of connections in the pool and also calls notify() . |
protected void |
finalize()
Deprecated. Close any open connections when this object is garbage collected. |
(package private) javax.sql.PooledConnection |
getConnection(java.lang.String username,
java.lang.String password)
Deprecated. Returns a connection that maintains a link to the pool it came from. |
private javax.sql.PooledConnection |
getInternalPooledConnection()
Deprecated. Gets a pooled database connection. |
(package private) int |
getNbrAvailable()
Deprecated. Returns the available connections in the pool |
(package private) int |
getNbrCheckedOut()
Deprecated. Returns the checked out connections in the pool |
private javax.sql.PooledConnection |
getNewConnection()
Deprecated. Returns a fresh connection to the database. |
(package private) java.lang.String |
getPoolName()
Deprecated. Get the name of the pool |
(package private) int |
getTotalCount()
Deprecated. Returns the Total connections in the pool |
private boolean |
isExpired(javax.sql.PooledConnection pc)
Deprecated. Helper method which determines whether a connection has expired. |
private boolean |
isValid(javax.sql.PooledConnection connection)
Deprecated. Determines if a connection is still valid. |
private javax.sql.PooledConnection |
popConnection()
Deprecated. Helper function that attempts to pop a connection off the pool's stack, handling the case where the popped connection has become invalid by creating a new connection. |
private void |
releaseConnection(javax.sql.PooledConnection pcon)
Deprecated. This method returns a connection to the pool, and must be called by the requestor when finished with the connection. |
(package private) void |
shutdown()
Deprecated. Close all connections to the database, |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_EXPIRY_TIME
public static final int DEFAULT_CONNECTION_WAIT_TIMEOUT
private java.util.Stack pool
private java.lang.String url
private java.lang.String username
private java.lang.String password
private int totalConnections
private int maxConnections
private long expiryTime
private int waitCount
private static org.apache.commons.logging.Log log
private int logInterval
private ConnectionPool.Monitor monitor
private long connectionWaitTimeout
private javax.sql.ConnectionPoolDataSource cpds
private java.util.Map timeStamps
Constructor Detail |
ConnectionPool(javax.sql.ConnectionPoolDataSource cpds, java.lang.String username, java.lang.String password, int maxConnections, int expiryTime, int connectionWaitTimeout, int logInterval)
ConnectionPool
with the default
attributes.
cpds
- The datasourceusername
- The user name for this pool.password
- The password for this pool.maxConnections
- max number of connectionsexpiryTime
- connection expiry timeconnectionWaitTimeout
- timeoutlogInterval
- log intervalMethod Detail |
final javax.sql.PooledConnection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
username
- The name of the database user.password
- The password of the database user.
java.sql.SQLException
- if there is aproblem with the db connectionprivate javax.sql.PooledConnection getNewConnection() throws java.sql.SQLException
driver
, and its connection
information by url
, username
, and
password
.
java.sql.SQLException
- if there is aproblem with the db connectionprivate javax.sql.PooledConnection getInternalPooledConnection() throws ConnectionWaitTimeoutException, java.lang.Exception
ConnectionWaitTimeoutException
- Wait time exceeded.
java.lang.Exception
- No pooled connections.private javax.sql.PooledConnection popConnection() throws java.lang.Exception
java.lang.Exception
- if the pool is emptyprivate boolean isExpired(javax.sql.PooledConnection pc)
pc
- The connection to test.
private boolean isValid(javax.sql.PooledConnection connection)
connection
- The connection to test.
protected void finalize() throws java.lang.Throwable
java.lang.Throwable
- Anything might happen...void shutdown()
int getTotalCount()
int getNbrAvailable()
int getNbrCheckedOut()
void decrementConnections()
notify()
.
java.lang.String getPoolName()
public void connectionClosed(javax.sql.ConnectionEvent event)
connectionClosed
in interface javax.sql.ConnectionEventListener
event
- the connection eventpublic void connectionErrorOccurred(javax.sql.ConnectionEvent event)
connectionErrorOccurred
in interface javax.sql.ConnectionEventListener
event
- the connection eventprivate void releaseConnection(javax.sql.PooledConnection pcon)
pcon
- The database connection to release.private void closePooledConnection(javax.sql.PooledConnection pcon)
pcon
- The database connection to close.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |