public class PooledConnection extends ConnectionDelegator
It is designed to be part of DataSourcePool. Closing the connection puts it back into the pool.
It defaults autoCommit and Transaction Isolation to the defaults of the DataSourcePool.
It has caching of Statements and PreparedStatements. Remembers the last statement that was executed. Keeps statistics on how long it is in use.
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor and Description |
|---|
PooledConnection(ConnectionPool pool,
int uniqueId,
Connection connection)
Construct the connection that can refer back to the pool it belongs to.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearWarnings() |
void |
close()
close the connection putting it back into the connection pool.
|
void |
commit() |
Statement |
createStatement()
Creates a wrapper ExtendedStatement so that I can get the executed sql.
|
Statement |
createStatement(int resultSetType,
int resultSetConcurreny) |
Statement |
createStatement(int i,
int x,
int y) |
boolean |
getAutoCommit() |
String |
getCatalog() |
int |
getHoldability() |
DatabaseMetaData |
getMetaData() |
int |
getTransactionIsolation() |
Map<String,Class<?>> |
getTypeMap() |
SQLWarning |
getWarnings() |
boolean |
isClosed() |
boolean |
isReadOnly() |
String |
nativeSQL(String sql) |
CallableStatement |
prepareCall(String sql) |
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurreny) |
CallableStatement |
prepareCall(String s,
int i,
int x,
int y) |
PreparedStatement |
prepareStatement(String sql)
This will try to use a cache of PreparedStatements.
|
PreparedStatement |
prepareStatement(String sql,
int returnKeysFlag)
This will try to use a cache of PreparedStatements.
|
PreparedStatement |
prepareStatement(String s,
int[] i) |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurreny) |
PreparedStatement |
prepareStatement(String s,
int i,
int x,
int y) |
PreparedStatement |
prepareStatement(String s,
String[] s2) |
void |
releaseSavepoint(Savepoint sp) |
void |
rollback() |
void |
rollback(Savepoint sp) |
void |
setAutoCommit(boolean autoCommit) |
void |
setCatalog(String catalog) |
void |
setHoldability(int i) |
void |
setLongRunning(boolean longRunning)
Set this to true if the connection is a long running connection and should skip the
'suspected connection pool leak' checking.
|
void |
setReadOnly(boolean readOnly)
Also note the read only status needs to be reset when put back into the
pool.
|
Savepoint |
setSavepoint() |
Savepoint |
setSavepoint(String savepointName) |
void |
setTransactionIsolation(int level)
Also note the Isolation level needs to be reset when put back into the
pool.
|
void |
setTypeMap(Map<String,Class<?>> map) |
String |
toString() |
abort, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStruct, getClientInfo, getClientInfo, getNetworkTimeout, getSchema, isValid, isWrapperFor, setClientInfo, setClientInfo, setNetworkTimeout, setSchema, unwrappublic PooledConnection(ConnectionPool pool, int uniqueId, Connection connection)
close() will return the connection back to the pool , while closeDestroy() will close() the underlining connection properly.
public void setLongRunning(boolean longRunning)
public Statement createStatement() throws SQLException
createStatement in interface ConnectioncreateStatement in class ConnectionDelegatorSQLExceptionpublic Statement createStatement(int resultSetType, int resultSetConcurreny) throws SQLException
createStatement in interface ConnectioncreateStatement in class ConnectionDelegatorSQLExceptionpublic PreparedStatement prepareStatement(String sql, int returnKeysFlag) throws SQLException
prepareStatement in interface ConnectionprepareStatement in class ConnectionDelegatorSQLExceptionpublic PreparedStatement prepareStatement(String sql) throws SQLException
prepareStatement in interface ConnectionprepareStatement in class ConnectionDelegatorSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurreny) throws SQLException
prepareStatement in interface ConnectionprepareStatement in class ConnectionDelegatorSQLExceptionpublic void close() throws SQLException
Note that to ensure that the next transaction starts at the correct time a commit() or rollback() should be called. If neither has occured at this time then a rollback() is used (to end the transaction).
To close the connection fully use closeConnectionFully().
close in interface AutoCloseableclose in interface Connectionclose in class ConnectionDelegatorSQLExceptionpublic void setReadOnly(boolean readOnly) throws SQLException
setReadOnly in interface ConnectionsetReadOnly in class ConnectionDelegatorSQLExceptionpublic void setTransactionIsolation(int level) throws SQLException
setTransactionIsolation in interface ConnectionsetTransactionIsolation in class ConnectionDelegatorSQLExceptionpublic void clearWarnings() throws SQLException
clearWarnings in interface ConnectionclearWarnings in class ConnectionDelegatorSQLExceptionpublic void commit() throws SQLException
commit in interface Connectioncommit in class ConnectionDelegatorSQLExceptionpublic boolean getAutoCommit() throws SQLException
getAutoCommit in interface ConnectiongetAutoCommit in class ConnectionDelegatorSQLExceptionpublic String getCatalog() throws SQLException
getCatalog in interface ConnectiongetCatalog in class ConnectionDelegatorSQLExceptionpublic DatabaseMetaData getMetaData() throws SQLException
getMetaData in interface ConnectiongetMetaData in class ConnectionDelegatorSQLExceptionpublic int getTransactionIsolation() throws SQLException
getTransactionIsolation in interface ConnectiongetTransactionIsolation in class ConnectionDelegatorSQLExceptionpublic Map<String,Class<?>> getTypeMap() throws SQLException
getTypeMap in interface ConnectiongetTypeMap in class ConnectionDelegatorSQLExceptionpublic SQLWarning getWarnings() throws SQLException
getWarnings in interface ConnectiongetWarnings in class ConnectionDelegatorSQLExceptionpublic boolean isClosed() throws SQLException
isClosed in interface ConnectionisClosed in class ConnectionDelegatorSQLExceptionpublic boolean isReadOnly() throws SQLException
isReadOnly in interface ConnectionisReadOnly in class ConnectionDelegatorSQLExceptionpublic String nativeSQL(String sql) throws SQLException
nativeSQL in interface ConnectionnativeSQL in class ConnectionDelegatorSQLExceptionpublic CallableStatement prepareCall(String sql) throws SQLException
prepareCall in interface ConnectionprepareCall in class ConnectionDelegatorSQLExceptionpublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurreny) throws SQLException
prepareCall in interface ConnectionprepareCall in class ConnectionDelegatorSQLExceptionpublic void rollback() throws SQLException
rollback in interface Connectionrollback in class ConnectionDelegatorSQLExceptionpublic void setAutoCommit(boolean autoCommit) throws SQLException
setAutoCommit in interface ConnectionsetAutoCommit in class ConnectionDelegatorSQLExceptionpublic void setCatalog(String catalog) throws SQLException
setCatalog in interface ConnectionsetCatalog in class ConnectionDelegatorSQLExceptionpublic void setTypeMap(Map<String,Class<?>> map) throws SQLException
setTypeMap in interface ConnectionsetTypeMap in class ConnectionDelegatorSQLExceptionpublic Savepoint setSavepoint() throws SQLException
setSavepoint in interface ConnectionsetSavepoint in class ConnectionDelegatorSQLExceptionpublic Savepoint setSavepoint(String savepointName) throws SQLException
setSavepoint in interface ConnectionsetSavepoint in class ConnectionDelegatorSQLExceptionpublic void rollback(Savepoint sp) throws SQLException
rollback in interface Connectionrollback in class ConnectionDelegatorSQLExceptionpublic void releaseSavepoint(Savepoint sp) throws SQLException
releaseSavepoint in interface ConnectionreleaseSavepoint in class ConnectionDelegatorSQLExceptionpublic void setHoldability(int i) throws SQLException
setHoldability in interface ConnectionsetHoldability in class ConnectionDelegatorSQLExceptionpublic int getHoldability() throws SQLException
getHoldability in interface ConnectiongetHoldability in class ConnectionDelegatorSQLExceptionpublic Statement createStatement(int i, int x, int y) throws SQLException
createStatement in interface ConnectioncreateStatement in class ConnectionDelegatorSQLExceptionpublic PreparedStatement prepareStatement(String s, int i, int x, int y) throws SQLException
prepareStatement in interface ConnectionprepareStatement in class ConnectionDelegatorSQLExceptionpublic PreparedStatement prepareStatement(String s, int[] i) throws SQLException
prepareStatement in interface ConnectionprepareStatement in class ConnectionDelegatorSQLExceptionpublic PreparedStatement prepareStatement(String s, String[] s2) throws SQLException
prepareStatement in interface ConnectionprepareStatement in class ConnectionDelegatorSQLExceptionpublic CallableStatement prepareCall(String s, int i, int x, int y) throws SQLException
prepareCall in interface ConnectionprepareCall in class ConnectionDelegatorSQLExceptionCopyright © 2016. All rights reserved.