|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.edg.security.voms.database.connection.ConnectionPool
A trivial database connection pool implementation. TODO: replace this hack with JNDI/JDBC-based real connection pools.
Field Summary | |
private static int |
DEFAULT_MAX_CONN
The default number of connections that may be open at once. |
private java.util.LinkedList |
freeConns
Queue of connections available for use. |
private static java.lang.String |
jdbcDriver
The JDBC driver to use. |
private static java.lang.String |
jdbcURL
The JDBC URL for the database. |
private static org.apache.log4j.Logger |
log
Logger. |
private static int |
MAX_WAIT_RETRIES
Do not repeat trying to get a new connection more that this number of times. |
protected int |
maxConn
Don't open more than this connections. |
protected java.lang.String |
name
The name of this pool (e.g. |
private java.lang.String |
password
Database password. |
private java.util.Set |
usedConns
Database connections currently in use. |
private java.lang.String |
username
Database username. |
Constructor Summary | |
protected |
ConnectionPool(java.lang.String name)
Constructor. |
protected |
ConnectionPool(java.lang.String name,
int maxConn)
|
Method Summary | |
boolean |
closeAll()
Close all free database connections. |
protected java.sql.Connection |
connect()
Return a new raw database handle. |
protected abstract ConnectionWrapper |
createConn()
Create a brand new connection. |
ConnectionWrapper |
get()
Return a ConnectionWrapper object from the connection pool. |
private int |
numConns()
|
void |
release(ConnectionWrapper c)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final int DEFAULT_MAX_CONN
private static final int MAX_WAIT_RETRIES
private static final transient org.apache.log4j.Logger log
protected int maxConn
private final java.util.LinkedList freeConns
private final java.util.Set usedConns
private static final java.lang.String jdbcDriver
private static final java.lang.String jdbcURL
private final java.lang.String username
private final java.lang.String password
protected final java.lang.String name
Constructor Detail |
protected ConnectionPool(java.lang.String name) throws GeneralDatabaseException
protected ConnectionPool(java.lang.String name, int maxConn)
Method Detail |
protected abstract ConnectionWrapper createConn() throws GeneralDatabaseException
GeneralDatabaseException
protected final java.sql.Connection connect() throws GeneralDatabaseException
GeneralDatabaseException
private final int numConns()
public ConnectionWrapper get() throws VOMSException
GeneralDatabaseException
- if a database error prevented the allocation of a connection.
VOMSException
public void release(ConnectionWrapper c)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean closeAll()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |