|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsophware.sql.ConnectionPool
ConnectionPool maintains a pool of database connetions to the
given database URL. Connections are extracted using the getConnection()
method and returned using returnConnection(). Connections that timeout
are automatically retired by the pool. All connections are guaranteed to
be in their default state when extracted.
It is assumed that all drivers were loaded prior to the first call to getConnection();
| Constructor Summary | |
ConnectionPool(java.lang.String URL,
java.lang.String user,
java.lang.String password,
int maxConn)
Creates new connection pool. |
|
| Method Summary | |
void |
dispose()
Closes all available connections. |
java.sql.Connection |
getConnection()
Checks out a connection from the pool. |
java.sql.Connection |
getConnection(long timeout)
Checks out a connection from the pool. |
int |
getIdleCount()
Get the number of connections currently idle |
int |
getSize()
Get the number of connections in the pool |
void |
returnConnection(java.sql.Connection con)
Checks in a connection to the pool. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConnectionPool(java.lang.String URL,
java.lang.String user,
java.lang.String password,
int maxConn)
URL - The JDBC URL for the databaseuser - The database user, or nullpassword - The database user password, or nullmaxConn - The maximal number of connections, or 0 for no limit| Method Detail |
public java.sql.Connection getConnection()
throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection getConnection(long timeout)
throws java.sql.SQLException
If no connection is available and the max number has been reached, this method waits the specified time for one to be checked in. A timeout value of zero waits indefinitely
timeout - The timeout value in milliseconds
java.sql.SQLExceptionpublic void returnConnection(java.sql.Connection con)
con - The connection to check inpublic int getIdleCount()
public int getSize()
public void dispose()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||