|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.ConnectionPool
A general purpose JDBC connection pool. There is normally a singleton pool object for an application, but you can have more than one if you need to manage a private pool.
JDBC drivers must be registered before you can establish a connection. There are three ways to do this: 1) the application handles it 2) the application calls ConnectionPool.registerDriver 3) the application calls getConnection and passes the driver info
If you only use one driver, the easiest thing is to call ConnectionPool.registerDriver during static initialization. If the driver can be specified at runtime as is the case with some resource adapters, then you can call the getConnection method that takes driver information.
Nested Class Summary | |
protected static class |
ConnectionPool.Bucket
A helper class that maintains a list of connections for a particular key. |
Field Summary | |
protected boolean |
_disabled
Flag to disable connection pooling. |
static java.lang.String |
code_id
|
Constructor Summary | |
ConnectionPool()
Create a private connection pool |
Method Summary | |
protected void |
addPooledConnection(PooledConnection con)
Add a connection back to the pool. |
void |
destroy(java.sql.Connection con)
Release a connection that has been misbehaving. |
void |
dump()
Dump information about the connections in the pool. |
void |
dump(java.lang.StringBuffer sb)
|
protected void |
dumpConnections(java.lang.StringBuffer sb)
Dumps the connection keys (JDBC URL,username) and the number of free connections into the provided buffer |
static void |
dumpGlobal()
|
static void |
dumpGlobal(java.lang.StringBuffer sb)
|
static void |
dumpPrivate(java.lang.StringBuffer sb)
|
void |
flush()
Close all connections in the pool. |
static void |
flushConnections()
Flush all connections in the global connection pool. |
static void |
flushPrivate()
|
java.sql.Connection |
getConnection(java.lang.String url,
java.lang.String user,
java.lang.String password)
Obtain a connection. |
java.sql.Connection |
getConnection(java.lang.String url,
java.lang.String user,
java.lang.String password,
boolean checkConnection)
Obtain a connection. |
java.sql.Connection |
getConnection(java.lang.String driverClass,
java.lang.String driverPrefix,
java.lang.String url,
java.lang.String user,
java.lang.String password)
Obtain a connection. |
java.sql.Connection |
getConnection(java.lang.String driverClass,
java.lang.String driverPrefix,
java.lang.String url,
java.lang.String user,
java.lang.String password,
boolean checkConnection)
Obtain a connection. |
static ConnectionPool |
getConnectionPool()
Get the global connection pool. |
protected int |
getFreeConnectionCount()
|
int |
getVersion()
Get the pool version number |
void |
incCreateStats()
Bump the active and total counts. |
void |
incDestroyStats()
Called by destroy below. |
protected static void |
println(java.lang.Object o)
|
static void |
registerDriver(java.lang.String driverClass)
|
static void |
registerDriver(java.lang.String driverClass,
java.lang.String prefix)
Helper method to register a driver. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
protected boolean _disabled
Constructor Detail |
public ConnectionPool()
Method Detail |
public static ConnectionPool getConnectionPool()
public static void flushConnections()
public int getVersion()
public static void registerDriver(java.lang.String driverClass) throws WavesetException
WavesetException
public static void registerDriver(java.lang.String driverClass, java.lang.String prefix) throws ConfigurationError
UPDATE: We're trying to reduce dependence on maintaining the prefix in the resource adapters. Instead, we now maintain a map of drivers we've already registerd which will keep us from hitting the DriverManager so often. I'm not sure if that's even a problem, but its safest to avoid if we can.
ConfigurationError
protected void addPooledConnection(PooledConnection con)
public void incDestroyStats()
public void incCreateStats()
public java.sql.Connection getConnection(java.lang.String url, java.lang.String user, java.lang.String password) throws WavesetException
WavesetException
public java.sql.Connection getConnection(java.lang.String url, java.lang.String user, java.lang.String password, boolean checkConnection) throws WavesetException
WavesetException
public java.sql.Connection getConnection(java.lang.String driverClass, java.lang.String driverPrefix, java.lang.String url, java.lang.String user, java.lang.String password) throws WavesetException
WavesetException
public java.sql.Connection getConnection(java.lang.String driverClass, java.lang.String driverPrefix, java.lang.String url, java.lang.String user, java.lang.String password, boolean checkConnection) throws WavesetException
WavesetException
public void flush()
public void destroy(java.sql.Connection con)
I don't know of a way to reliably test this within ConnectionPool other than to try to call some harmless request such as rollback(), but that would cause another server round trip. For now, I'm assuming the application can handle that.
public void dump()
public void dump(java.lang.StringBuffer sb)
protected int getFreeConnectionCount()
protected void dumpConnections(java.lang.StringBuffer sb)
sb
- buffer to write messages toprotected static void println(java.lang.Object o)
public static void dumpGlobal()
public static void dumpGlobal(java.lang.StringBuffer sb)
public static void dumpPrivate(java.lang.StringBuffer sb)
public static void flushPrivate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |