|
: Class ConnectionPoolManager
com.bitmechanic.sql
|
Field Summary | |
static java.lang.String |
URL_PREFIX
|
Constructor Summary | |
ConnectionPoolManager()
Creates a pool that doesn't monitor itself to check for idle/stale connections. |
|
ConnectionPoolManager(int monitorInterval)
Creates a pool with a monitoring thread that checks the pool to make sure no connections are stale or idle. |
Method Summary | |
boolean |
acceptsURL(java.lang.String url)
Returns true of url starts with URL_PREFIX |
void |
addAlias(ConnectionPool pool)
Adds an alias to the pool using a supplied ConnectionPool object. |
void |
addAlias(java.lang.String alias,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxConn,
int idleTimeout,
int checkoutTimeout)
Adds an alias to the pool. |
void |
addAlias(java.lang.String alias,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxConn,
int idleTimeout,
int checkoutTimeout,
int maxCheckout)
Adds an alias to the pool. |
void |
addAlias(java.lang.String alias,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxConn,
int idleTimeout,
int checkoutTimeout,
int maxCheckout,
boolean cacheStatements)
Adds an alias to the pool. |
void |
addAlias(java.lang.String alias,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxConn,
int idleTimeout,
int checkoutTimeout,
int maxCheckout,
int rowPrefetch)
Adds an alias to the pool. |
void |
addAlias(java.lang.String alias,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxConn,
int idleTimeout,
int checkoutTimeout,
int maxCheckout,
int rowPrefetch,
boolean cacheStatements)
Adds an alias to the pool. |
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties props)
Returns a connection from pool |
java.lang.String |
dumpInfo()
Dump some information about all connections and pools into a String |
int |
getMajorVersion()
|
int |
getMinorVersion()
|
ConnectionPool |
getPool(java.lang.String alias)
Returns the pool with the supplied alias |
java.util.Enumeration |
getPools()
Returns an Enumeration of the ConnectionPool objects currently created |
java.sql.DriverPropertyInfo[] |
getPropertyInfo(java.lang.String str,
java.util.Properties props)
|
boolean |
jdbcCompliant()
Always returns false since I haven't sent this code to Sun for approval |
void |
removeAlias(java.lang.String alias)
Closes all Connections in the pool with the supplied alias |
void |
run()
Monitors each ConnectionPool and makes sure that no connection has gone idle or has been checked out for too long. |
void |
setTracing(boolean on)
Turns tracing on or off. |
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 URL_PREFIX
Constructor Detail |
public ConnectionPoolManager() throws java.sql.SQLException
public ConnectionPoolManager(int monitorInterval) throws java.sql.SQLException
monitorInterval
- number of seconds between checks on the poolMethod Detail |
public void addAlias(java.lang.String alias, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int maxConn, int idleTimeout, int checkoutTimeout) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
idleTimeout and checkoutTimeout are expressed in seconds
maxCheckouts is unlimited
cacheStatements is set to 'true' by default
alias
- Name of the pooldriver
- Classname of JDBC driver to useurl
- JDBC URL to connect tousername
- JDBC username to connect aspassword
- username's password in the databasemaxConn
- Maximum number of connections to open; When this limit
is reached, threads requesting a connection are queued
until a connection becomes availableidleTimeout
- Maximum number of seconds a Connection can go
unused before it is closedcheckoutTimeout
- Maximum number of seconds a Thread can checkout a
Connection before it is closed and returned to the
pool. This is a protection against the Thread
dying and leaving the Connection checked out
indefinatelypublic void addAlias(java.lang.String alias, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int maxConn, int idleTimeout, int checkoutTimeout, int maxCheckout) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
idleTimeout and checkoutTimeout are expressed in seconds
cacheStatements is set to 'true' by default
alias
- Name of the pooldriver
- Classname of JDBC driver to useurl
- JDBC URL to connect tousername
- JDBC username to connect aspassword
- username's password in the databasemaxConn
- Maximum number of connections to open; When this limit
is reached, threads requesting a connection are queued
until a connection becomes availableidleTimeout
- Maximum number of seconds a Connection can go
unused before it is closedcheckoutTimeout
- Maximum number of seconds a Thread can checkout a
Connection before it is closed and returned to the
pool. This is a protection against the Thread
dying and leaving the Connection checked out
indefinatelymaxCheckout
- If this is greater than 0, the number of times a
Connection may be checked out before it is closed.
Used as a safeguard against cursor leak, which occurs
if you don't call ResultSet.close() and
Statement.close()public void addAlias(java.lang.String alias, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int maxConn, int idleTimeout, int checkoutTimeout, int maxCheckout, boolean cacheStatements) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
idleTimeout and checkoutTimeout are expressed in seconds
alias
- Name of the pooldriver
- Classname of JDBC driver to useurl
- JDBC URL to connect tousername
- JDBC username to connect aspassword
- username's password in the databasemaxConn
- Maximum number of connections to open; When this limit
is reached, threads requesting a connection are queued
until a connection becomes availableidleTimeout
- Maximum number of seconds a Connection can go
unused before it is closedcheckoutTimeout
- Maximum number of seconds a Thread can checkout a
Connection before it is closed and returned to the
pool. This is a protection against the Thread
dying and leaving the Connection checked out
indefinatelymaxCheckout
- If this is greater than 0, the number of times a
Connection may be checked out before it is closed.
Used as a safeguard against cursor leak, which occurs
if you don't call ResultSet.close() and
Statement.close()cacheStatements
- If set to true, the PooledConnection will reuse
the same Statement object when conn.createStatement() is called.
It will also cache PreparedStatements.public void addAlias(java.lang.String alias, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int maxConn, int idleTimeout, int checkoutTimeout, int maxCheckout, int rowPrefetch) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
idleTimeout and checkoutTimeout are expressed in seconds
cacheStatements is set to 'true' by default
alias
- Name of the pooldriver
- Classname of JDBC driver to useurl
- JDBC URL to connect tousername
- JDBC username to connect aspassword
- username's password in the databasemaxConn
- Maximum number of connections to open; When this limit
is reached, threads requesting a connection are queued
until a connection becomes availableidleTimeout
- Maximum number of seconds a Connection can go
unused before it is closedcheckoutTimeout
- Maximum number of seconds a Thread can checkout a
Connection before it is closed and returned to the
pool. This is a protection against the Thread
dying and leaving the Connection checked out
indefinatelymaxCheckout
- If this is greater than 0, the number of times a
Connection may be checked out before it is closed.
Used as a safeguard against cursor leak, which occurs
if you don't call ResultSet.close() and
Statement.close()rowPrefetch
- If your db driver supports a row prefetch size (Oracle does)
use this value for row prefetch, -1 for the defaultpublic void addAlias(java.lang.String alias, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int maxConn, int idleTimeout, int checkoutTimeout, int maxCheckout, int rowPrefetch, boolean cacheStatements) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
idleTimeout and checkoutTimeout are expressed in seconds
alias
- Name of the pooldriver
- Classname of JDBC driver to useurl
- JDBC URL to connect tousername
- JDBC username to connect aspassword
- username's password in the databasemaxConn
- Maximum number of connections to open; When this limit
is reached, threads requesting a connection are queued
until a connection becomes availableidleTimeout
- Maximum number of seconds a Connection can go
unused before it is closedcheckoutTimeout
- Maximum number of seconds a Thread can checkout a
Connection before it is closed and returned to the
pool. This is a protection against the Thread
dying and leaving the Connection checked out
indefinatelymaxCheckout
- If this is greater than 0, the number of times a
Connection may be checked out before it is closed.
Used as a safeguard against cursor leak, which occurs
if you don't call ResultSet.close() and
Statement.close()rowPrefetch
- If your db driver supports a row prefetch size (Oracle does)
use this value for row prefetch, -1 for the defaultcacheStatements
- If set to true, the PooledConnection will reuse
the same Statement object when conn.createStatement() is called.
It will also cache PreparedStatements.public void addAlias(ConnectionPool pool)
Beware! - this will not call Class.forName() on the JDBC driver for you. Make sure to call that before calling this method or the driver will not work (getConnection() will fail)
public void removeAlias(java.lang.String alias) throws java.sql.SQLException
public java.util.Enumeration getPools()
public ConnectionPool getPool(java.lang.String alias) throws java.sql.SQLException
public void run()
public void setTracing(boolean on)
public java.sql.Connection connect(java.lang.String url, java.util.Properties props) throws java.sql.SQLException
public boolean acceptsURL(java.lang.String url)
public int getMajorVersion()
public int getMinorVersion()
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String str, java.util.Properties props)
public boolean jdbcCompliant()
public java.lang.String dumpInfo()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |