public class ConnectionPool extends Object
| Constructor and Description |
|---|
ConnectionPool(String driver,
String url,
String username,
String password,
DDLConverter ddlConverter,
int maxActive,
int maxIdle,
long maxWait,
int minIdle,
long minEvictableIdleTimeMillis,
int numTestsPerEvictionRun,
long timeBetweenEvictionRunsMillis,
String validationQuery,
boolean testOnBorrow,
boolean testOnReturn,
boolean testWhileIdle,
byte whenExhaustedAction)
Constructs a ConnectionPool that can provide TableCreatingConnections.
|
ConnectionPool(String driver,
String url,
String username,
String password,
int maxActive,
int maxIdle,
long maxWait,
int minIdle,
long minEvictableIdleTimeMillis,
int numTestsPerEvictionRun,
long timeBetweenEvictionRunsMillis,
String validationQuery,
boolean testOnBorrow,
boolean testOnReturn,
boolean testWhileIdle,
byte whenExhaustedAction)
Constructs a ConnectionPool based on the calling arguments.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying data source
|
void |
free(Connection connection)
Releases the specified connection and returns it to the pool.
|
Connection |
getReadOnlyConnection()
Gets the next available connection.
|
Connection |
getReadWriteConnection()
Gets the next available connection.
|
TableCreatingConnection |
getTableCreatingConnection()
Gets a TableCreatingConnection.
|
protected void |
setConnectionProperties(Map<String,String> props) |
String |
toString() |
public ConnectionPool(String driver, String url, String username, String password, int maxActive, int maxIdle, long maxWait, int minIdle, long minEvictableIdleTimeMillis, int numTestsPerEvictionRun, long timeBetweenEvictionRunsMillis, String validationQuery, boolean testOnBorrow, boolean testOnReturn, boolean testWhileIdle, byte whenExhaustedAction) throws SQLException
Constructs a ConnectionPool based on the calling arguments.
driver - The JDBC driver class name.url - The JDBC connection URL.username - The database user name.password - The database password.maxActive - Maximum number of active instances in pool.maxIdle - Maximum number of idle instances in pool.maxWait - Maximum amount of time in milliseconds the borrowObject() method
should wait when whenExhaustedAction is set to
WHEN_EXHAUSTED_BLOCK.minIdle - Minimum of idle instances in pool.minEvictableIdleTimeMillis - Minimum amount of time in milliseconds an object can be idle in
pool before eligible for eviction (if applicable).numTestsPerEvictionRun - Number of objects to be examined on each run of idle evictor
thread (if applicable).timeBetweenEvictionRunsMillis - Time in milliseconds to sleep between runs of the idle object
evictor thread.validationQuery - Query to run when validation connections, e.g. SELECT 1.testOnBorrow - When true objects are validated before borrowed from the pool.testOnReturn - When true, objects are validated before returned to hte pool.testWhileIdle - When true, objects are validated by the idle object evictor
thread.whenExhaustedAction - Action to take when a new object is requested and the the pool has
reached maximum number of active objects.SQLException - If the connection pool cannot be established for any reason.public ConnectionPool(String driver, String url, String username, String password, DDLConverter ddlConverter, int maxActive, int maxIdle, long maxWait, int minIdle, long minEvictableIdleTimeMillis, int numTestsPerEvictionRun, long timeBetweenEvictionRunsMillis, String validationQuery, boolean testOnBorrow, boolean testOnReturn, boolean testWhileIdle, byte whenExhaustedAction) throws SQLException
driver - The JDBC driver class name.url - The JDBC connection URL.username - The database user name.password - The he database password.ddlConverter - The DDLConverter that the TableCreatingConnections should use when
createTable(TableSpec) is called.maxActive - Maximum number of active instances in pool.maxIdle - Maximum number of idle instances in pool.maxWait - Maximum amount of time in milliseconds the borrowObject() method
should wait when whenExhaustedAction is set to
WHEN_EXHAUSTED_BLOCK.minIdle - Minimum of idle instances in pool.minEvictableIdleTimeMillis - Minimum amount of time in milliseconds an object can be idle in
pool before eligible for eviction (if applicable).numTestsPerEvictionRun - Number of objects to be examined on each run of idle evictor
thread (if applicable).timeBetweenEvictionRunsMillis - Time in milliseconds to sleep between runs of the idle object
evictor thread.validationQuery - Query to run when validation connections, e.g. SELECT 1.testOnBorrow - When true objects are validated before borrowed from the pool.testOnReturn - When true, objects are validated before returned to hte pool.testWhileIdle - When true, objects are validated by the idle object evictor
thread.whenExhaustedAction - Action to take when a new object is requested and the the pool has
reached maximum number of active objects.SQLException - If the connection pool cannot be established for any reason.public TableCreatingConnection getTableCreatingConnection() throws SQLException
This derives from the same pool, but wraps the Connection in an appropriate TableCreatingConnection before returning it.
SQLException - If there is any propblem in getting the SQL connection.public Connection getReadOnlyConnection() throws SQLException
Gets the next available connection. Connection is read-only, see getReadWriteConnection() for performing updates
SQLException - If the maximum number of connections has been reached or there is
some other problem in obtaining the connection.public Connection getReadWriteConnection() throws SQLException
Gets the next available connection. Connection is read-write, only use if updates are to be performed, otherwise use getReadOnlyConnection()
SQLException - If the maximum number of connections has been reached or there is
some other problem in obtaining the connection.public void free(Connection connection)
Releases the specified connection and returns it to the pool.
connection - A JDBC connection.public void close()
Closes the underlying data source
Copyright © 2013 DuraSpace. All Rights Reserved.