|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jolbox.bonecp.ConnectionHandle
public class ConnectionHandle
Connection handle wrapper around a JDBC connection.
| Field Summary | |
|---|---|
protected boolean |
logicallyClosed
If true, we've called close() on this connection. |
protected boolean |
possiblyBroken
If true, this connection might have failed communicating with the database. |
protected TransactionRecoveryResult |
recoveryResult
Map of translations + result from last recovery. |
protected boolean |
statementCachingEnabled
Set to true if we have statement caching enabled. |
protected Thread |
threadUsingConnection
Keep track of the thread. |
protected String |
url
Connection url. |
| Fields inherited from interface java.sql.Connection |
|---|
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Constructor Summary | |
|---|---|
ConnectionHandle(Connection connection,
IStatementCache preparedStatementCache,
IStatementCache callableStatementCache,
BoneCP pool)
Private constructor used solely for unit testing. |
|
ConnectionHandle(String url,
String username,
String password,
BoneCP pool)
Connection wrapper constructor |
|
| Method Summary | ||
|---|---|---|
protected void |
clearStatementCaches(boolean internalClose)
Clears out the statement handles. |
|
void |
clearWarnings()
|
|
void |
close()
Release the connection if called. |
|
void |
commit()
|
|
Array |
createArrayOf(String typeName,
Object[] elements)
|
|
Blob |
createBlob()
|
|
Clob |
createClob()
|
|
NClob |
createNClob()
|
|
SQLXML |
createSQLXML()
|
|
Statement |
createStatement()
|
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
|
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
|
|
Struct |
createStruct(String typeName,
Object[] attributes)
|
|
boolean |
getAutoCommit()
|
|
String |
getCatalog()
|
|
Properties |
getClientInfo()
|
|
String |
getClientInfo(String name)
|
|
long |
getConnectionCreationTime()
Deprecated. please use getConnectionCreationTimeInMs() instead. |
|
long |
getConnectionCreationTimeInMs()
Returns the connectionCreationTime field. |
|
ConnectionHook |
getConnectionHook()
Returns the configured connection hook object. |
|
long |
getConnectionLastReset()
Deprecated. Please use getConnectionLastResetInMs() instead |
|
long |
getConnectionLastResetInMs()
|
|
long |
getConnectionLastUsed()
Deprecated. Use getConnectionLastUsedInMs() instead. |
|
long |
getConnectionLastUsedInMs()
|
|
Object |
getDebugHandle()
Returns a debug handle as previously set by an application |
|
int |
getHoldability()
|
|
Connection |
getInternalConnection()
Returns the internal connection as obtained via the JDBC driver. |
|
DatabaseMetaData |
getMetaData()
|
|
ConnectionPartition |
getOriginatingPartition()
Gets the partition this came from. |
|
BoneCP |
getPool()
Returns a handle to the global pool from where this connection was obtained. |
|
Object |
getProxyTarget()
This method will be intercepted by the proxy if it is enabled to return the internal target. |
|
Connection |
getRawConnection()
Deprecated. |
|
List<ReplayLog> |
getReplayLog()
Returns transaction history log |
|
Thread |
getThreadUsingConnection()
Returns the thread that is currently utilizing this connection. |
|
Thread |
getThreadWatch()
Returns the thread watching over this connection. |
|
int |
getTransactionIsolation()
|
|
Map<String,Class<?>> |
getTypeMap()
|
|
SQLWarning |
getWarnings()
|
|
protected void |
internalClose()
Close off the connection. |
|
boolean |
isClosed()
Returns true if this connection has been (logically) closed. |
|
boolean |
isConnectionAlive()
Sends a test query to the underlying connection and return true if connection is alive. |
|
boolean |
isExpired()
Returns true if the given connection has exceeded the maxConnectionAge. |
|
protected boolean |
isExpired(long currentTime)
Returns true if the given connection has exceeded the maxConnectionAge. |
|
protected boolean |
isInReplayMode()
|
|
boolean |
isLogStatementsEnabled()
Returns true if logging of statements is enabled |
|
boolean |
isPossiblyBroken()
Gets true if connection has triggered an exception at some point. |
|
boolean |
isReadOnly()
|
|
boolean |
isValid(int timeout)
|
|
boolean |
isWrapperFor(Class<?> iface)
|
|
protected SQLException |
markPossiblyBroken(SQLException e)
Given an exception, flag the connection (or database) as being potentially broken. |
|
String |
nativeSQL(String sql)
|
|
protected Connection |
obtainInternalConnection()
Obtains a database connection, retrying if necessary. |
|
CallableStatement |
prepareCall(String sql)
|
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
|
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
|
|
PreparedStatement |
prepareStatement(String sql)
|
|
PreparedStatement |
prepareStatement(String sql,
int autoGeneratedKeys)
|
|
PreparedStatement |
prepareStatement(String sql,
int[] columnIndexes)
|
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
|
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
|
|
PreparedStatement |
prepareStatement(String sql,
String[] columnNames)
|
|
void |
releaseSavepoint(Savepoint savepoint)
|
|
protected void |
renewConnection()
Renews this connection, i.e. |
|
void |
rollback()
|
|
void |
rollback(Savepoint savepoint)
|
|
void |
sendInitSQL()
Sends any configured SQL init statement. |
|
void |
setAutoCommit(boolean autoCommit)
|
|
void |
setCatalog(String catalog)
|
|
void |
setClientInfo(Properties properties)
|
|
void |
setClientInfo(String name,
String value)
|
|
protected void |
setConnectionLastResetInMs(long connectionLastReset)
|
|
protected void |
setConnectionLastUsedInMs(long connectionLastUsed)
|
|
void |
setDebugHandle(Object debugHandle)
Sets a debugHandle, an object that is not used by the connection pool at all but may be set by an application to track this particular connection handle for any purpose it deems fit. |
|
void |
setHoldability(int holdability)
|
|
protected void |
setInReplayMode(boolean inReplayMode)
|
|
void |
setInternalConnection(Connection rawConnection)
Sets the internal connection to use. |
|
void |
setLogStatementsEnabled(boolean logStatementsEnabled)
Enable or disable logging of this connection. |
|
protected void |
setOriginatingPartition(ConnectionPartition originatingPartition)
Sets Originating partition |
|
void |
setReadOnly(boolean readOnly)
|
|
protected void |
setReplayLog(List<ReplayLog> replayLog)
Sets the transaction history log |
|
Savepoint |
setSavepoint()
|
|
Savepoint |
setSavepoint(String name)
|
|
protected void |
setThreadWatch(Thread threadWatch)
Sets the thread watching over this connection. |
|
void |
setTransactionIsolation(int level)
|
|
void |
setTypeMap(Map<String,Class<?>> map)
|
|
|
unwrap(Class<T> iface)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean possiblyBroken
protected boolean logicallyClosed
protected boolean statementCachingEnabled
protected TransactionRecoveryResult recoveryResult
protected String url
protected Thread threadUsingConnection
| Constructor Detail |
|---|
public ConnectionHandle(String url,
String username,
String password,
BoneCP pool)
throws SQLException
url - JDBC connection stringusername - user to usepassword - password for dbpool - pool handle.
SQLException - on error
public ConnectionHandle(Connection connection,
IStatementCache preparedStatementCache,
IStatementCache callableStatementCache,
BoneCP pool)
connection - preparedStatementCache - callableStatementCache - pool - | Method Detail |
|---|
protected Connection obtainInternalConnection()
throws SQLException
SQLException
public void sendInitSQL()
throws SQLException
SQLException - on errorprotected SQLException markPossiblyBroken(SQLException e)
e - SQLException e
public void clearWarnings()
throws SQLException
clearWarnings in interface ConnectionSQLException
public void close()
throws SQLException
close in interface ConnectionSQLException - Never really thrown
protected void internalClose()
throws SQLException
SQLException
public void commit()
throws SQLException
commit in interface ConnectionSQLException
public Properties getClientInfo()
throws SQLException
getClientInfo in interface ConnectionSQLException
public String getClientInfo(String name)
throws SQLException
getClientInfo in interface ConnectionSQLException
public boolean isValid(int timeout)
throws SQLException
isValid in interface ConnectionSQLException
public boolean isWrapperFor(Class<?> iface)
throws SQLException
isWrapperFor in interface WrapperSQLException
public <T> T unwrap(Class<T> iface)
throws SQLException
unwrap in interface WrapperSQLException
public void setClientInfo(Properties properties)
throws SQLClientInfoException
setClientInfo in interface ConnectionSQLClientInfoException
public void setClientInfo(String name,
String value)
throws SQLClientInfoException
setClientInfo in interface ConnectionSQLClientInfoException
public Struct createStruct(String typeName,
Object[] attributes)
throws SQLException
createStruct in interface ConnectionSQLException
public Array createArrayOf(String typeName,
Object[] elements)
throws SQLException
createArrayOf in interface ConnectionSQLException
public Blob createBlob()
throws SQLException
createBlob in interface ConnectionSQLException
public Clob createClob()
throws SQLException
createClob in interface ConnectionSQLException
public NClob createNClob()
throws SQLException
createNClob in interface ConnectionSQLException
public SQLXML createSQLXML()
throws SQLException
createSQLXML in interface ConnectionSQLException
public Statement createStatement()
throws SQLException
createStatement in interface ConnectionSQLException
public Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException
createStatement in interface ConnectionSQLException
public Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
createStatement in interface ConnectionSQLException
public boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLException
public String getCatalog()
throws SQLException
getCatalog in interface ConnectionSQLException
public int getHoldability()
throws SQLException
getHoldability in interface ConnectionSQLException
public DatabaseMetaData getMetaData()
throws SQLException
getMetaData in interface ConnectionSQLException
public int getTransactionIsolation()
throws SQLException
getTransactionIsolation in interface ConnectionSQLException
public Map<String,Class<?>> getTypeMap()
throws SQLException
getTypeMap in interface ConnectionSQLException
public SQLWarning getWarnings()
throws SQLException
getWarnings in interface ConnectionSQLExceptionpublic boolean isClosed()
isClosed in interface Connection
public boolean isReadOnly()
throws SQLException
isReadOnly in interface ConnectionSQLException
public String nativeSQL(String sql)
throws SQLException
nativeSQL in interface ConnectionSQLException
public CallableStatement prepareCall(String sql)
throws SQLException
prepareCall in interface ConnectionSQLException
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareCall in interface ConnectionSQLException
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
prepareCall in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int autoGeneratedKeys)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int[] columnIndexes)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
String[] columnNames)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
prepareStatement in interface ConnectionSQLException
public void releaseSavepoint(Savepoint savepoint)
throws SQLException
releaseSavepoint in interface ConnectionSQLException
public void rollback()
throws SQLException
rollback in interface ConnectionSQLException
public void rollback(Savepoint savepoint)
throws SQLException
rollback in interface ConnectionSQLException
public void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionSQLException
public void setCatalog(String catalog)
throws SQLException
setCatalog in interface ConnectionSQLException
public void setHoldability(int holdability)
throws SQLException
setHoldability in interface ConnectionSQLException
public void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly in interface ConnectionSQLException
public Savepoint setSavepoint()
throws SQLException
setSavepoint in interface ConnectionSQLException
public Savepoint setSavepoint(String name)
throws SQLException
setSavepoint in interface ConnectionSQLException
public void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation in interface ConnectionSQLException
public void setTypeMap(Map<String,Class<?>> map)
throws SQLException
setTypeMap in interface ConnectionSQLExceptionpublic long getConnectionLastUsedInMs()
@Deprecated public long getConnectionLastUsed()
getConnectionLastUsedInMs() instead.
getConnectionLastUsedInMs() instead.
protected void setConnectionLastUsedInMs(long connectionLastUsed)
connectionLastUsed - the connectionLastUsed to setpublic long getConnectionLastResetInMs()
@Deprecated public long getConnectionLastReset()
getConnectionLastResetInMs() instead
getConnectionLastResetInMs() instead.
protected void setConnectionLastResetInMs(long connectionLastReset)
connectionLastReset - the connectionLastReset to setpublic boolean isPossiblyBroken()
public ConnectionPartition getOriginatingPartition()
protected void setOriginatingPartition(ConnectionPartition originatingPartition)
originatingPartition - to setprotected void renewConnection()
protected void clearStatementCaches(boolean internalClose)
internalClose - if true, close the inner statement handle too.public Object getDebugHandle()
public void setDebugHandle(Object debugHandle)
debugHandle - any object.@Deprecated public Connection getRawConnection()
public Connection getInternalConnection()
public ConnectionHook getConnectionHook()
public boolean isLogStatementsEnabled()
public void setLogStatementsEnabled(boolean logStatementsEnabled)
logStatementsEnabled - true to enable logging, false to disable.protected boolean isInReplayMode()
protected void setInReplayMode(boolean inReplayMode)
inReplayMode - the inReplayMode to setpublic boolean isConnectionAlive()
public void setInternalConnection(Connection rawConnection)
rawConnection - to setpublic BoneCP getPool()
public List<ReplayLog> getReplayLog()
protected void setReplayLog(List<ReplayLog> replayLog)
replayLog - to set.public Object getProxyTarget()
public Thread getThreadUsingConnection()
@Deprecated public long getConnectionCreationTime()
getConnectionCreationTimeInMs() instead.
getConnectionCreationTimeInMs() instead.
public long getConnectionCreationTimeInMs()
public boolean isExpired()
protected boolean isExpired(long currentTime)
currentTime - current time to use.
protected void setThreadWatch(Thread threadWatch)
threadWatch - the threadWatch to setpublic Thread getThreadWatch()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||