|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.apache.turbine.util.db.pool.ConnectionPool
This class implements a simple connection pooling scheme. Multiple
pools are available through use of the PoolBrokerService.
| Constructor Summary | |
ConnectionPool()
Deprecated. Use the constructor specifying db parameters. |
|
ConnectionPool(int maxCons,
long expiryTime)
Deprecated. Use the constructor specifying db parameters. |
|
ConnectionPool(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password)
Creates a ConnectionPool with the default
attributes. |
|
ConnectionPool(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxCons,
long expiryTime)
Creates a ConnectionPool with the specified
attributes. |
|
| Method Summary | |
void |
decrementConnections()
Decreases the count of connections in the pool and also calls notify(). |
protected void |
finalize()
Close any open connections when this object is garbage collected. |
DBConnection |
getConnection()
Returns a connection that maintains a link to the pool it came from. |
DBConnection |
getConnection(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password)
Deprecated. Database parameters should not be specified each time a DBConnection is fetched from the pool. |
DB |
getDB()
Returns an instance of the database adapter associated with this pool. |
int |
getLoginTimeout()
|
java.io.PrintWriter |
getLogWriter()
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. |
int |
getNbrAvailable()
Returns the available connections in the pool |
int |
getNbrCheckedOut()
Returns the checked out connections in the pool |
protected DBConnection |
getNewConnection()
Returns a fresh connection to the database. |
javax.sql.PooledConnection |
getPooledConnection()
Attempt to establish a database connection. |
javax.sql.PooledConnection |
getPooledConnection(java.lang.String user,
java.lang.String password)
Attempt to establish a database connection. |
int |
getTotalCount()
Re turns the Total connections in the pool |
void |
releaseConnection(DBConnection dbconn)
This method returns a connection to the pool, and must be called by the requestor when finished with the connection. |
void |
setLoginTimeout(int seconds)
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. |
void |
setLogWriter(java.io.PrintWriter out)
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. |
void |
shutdown()
Close all connections to the database, |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConnectionPool()
ConnectionPool with the default
attributes.
public ConnectionPool(int maxCons,
long expiryTime)
ConnectionPool with the specified
attributes.
maxCons - The maximum number of connections for this pool.expiryTime - The expiration time in milliseconds.
public ConnectionPool(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password)
ConnectionPool with the default
attributes.
driver - The driver type for this pool.url - The url for this pool.password - The password for this pool.
public ConnectionPool(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxCons,
long expiryTime)
ConnectionPool with the specified
attributes.
driver - The driver type for this pool.url - The url for this pool.password - The password for this pool.maxCons - The maximum number of connections for this pool.expiryTime - The expiration time in milliseconds.| Method Detail |
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - Anything might happen...
public javax.sql.PooledConnection getPooledConnection()
throws java.sql.SQLException
java.sql.SQLException
public javax.sql.PooledConnection getPooledConnection(java.lang.String user,
java.lang.String password)
throws java.sql.SQLException
java.sql.SQLException
public final DBConnection getConnection()
throws java.lang.Exception
java.lang.Exception
public final DBConnection getConnection(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password)
throws java.lang.Exception
driver - The fully-qualified name of the JDBC driver to use.url - The URL of the database from which the connection is
desired.username - The name of the database user.password - The password of the database user.
Exception.
java.lang.Exception
public DB getDB()
throws java.lang.Exception
DB associated with this pool.
java.lang.Exception
public java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out)
throws java.sql.SQLException
java.sql.SQLException
public void setLoginTimeout(int seconds)
throws java.sql.SQLException
java.sql.SQLException
public int getLoginTimeout()
throws java.sql.SQLException
java.sql.SQLException
protected DBConnection getNewConnection()
throws java.lang.Exception
driver, and its connection
information by url, username, and
password.
java.lang.Exception
public void releaseConnection(DBConnection dbconn)
throws java.lang.Exception
java.lang.Exception - Trouble releasing the connection.public void shutdown()
public int getTotalCount()
public int getNbrAvailable()
public int getNbrCheckedOut()
public void decrementConnections()
notify().
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||