|
EspressReport v 6.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--quadbase.common.util.internal.ConnectionPool
A class that manages a set of open Connection objects. This class is used
mainly by QbConnection. The logic of the ConnectionPool manager is as follows:
A Vector is used to hold a set of ConectionDetail objects. A ConnectionDetail object
basically contains a variable that holds the underlying java.sql.Connection, and some
information about the Connection itself (dburl, username, password) so that it may use
these information to reconnect if necessary.
User of this class simply calls getConnection to get a QbConnection object. Depending on
the state of the ConnectionPool, a new QbConnection (thus a java.sql.Connection) is
created or an unused QbConnection object is fetched and returned from the pool.
If the current size of the pool (the number of Connections in the pool) is less than
its capacity, then a new Qbconnection is created. If the forceAllocate flag is true
when calling the getConnection method, a new QbConnection is created. If the size of the
pool is the same as the capacity, then it will first look for an available (unused/free)
and matching (same url, user, passwd) QbConnection to return to the user. If none is
found, then it will allocate a new QbConnection object outside of the pool to return to
the user. The QbConection that is allocated outside of the pool is not put inside the
pool and will never be reused once it is closed.
Read the getConnection method for more details on how ConnectionPool works.
| Constructor Summary | |
ConnectionPool()
Allocates a new ConnectionPool. |
|
| Method Summary | |
int |
capacity()
the size limit of the pool |
void |
cleanup()
Removes unused connection(s) from the pool. |
void |
close(QbConnection qbc,
java.sql.Connection c)
Close the connection. |
java.sql.Connection |
getConnection(java.lang.String url,
java.util.Properties info,
boolean forceAllocate)
If the pool is not full, create a new QbCoonnection, put it in the pool and return the QbConnection to the user. |
java.sql.Connection |
removeAndGetConnection(java.sql.Connection c,
java.lang.String url,
java.util.Properties info)
removes the specified connection from the pool, and get a new connection which must be a newly allocated connection. |
int |
size()
The number of Connections in the pool. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConnectionPool()
| Method Detail |
public int capacity()
public int size()
public void cleanup()
public java.sql.Connection getConnection(java.lang.String url,
java.util.Properties info,
boolean forceAllocate)
throws java.sql.SQLException
url - the url where the database instance residesinfo - at least "user" and "password"
public java.sql.Connection removeAndGetConnection(java.sql.Connection c,
java.lang.String url,
java.util.Properties info)
throws java.sql.SQLException
public void close(QbConnection qbc,
java.sql.Connection c)
throws java.sql.SQLException
|
EspressReport v 6.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||