|
|
|
@ -60,7 +60,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
|
|
|
|
|
@HikariInject protected ThreadLocal<Boolean> _isClosed;
|
|
|
|
|
|
|
|
|
|
@HikariInject protected ArrayList<Statement> _openStatements;
|
|
|
|
|
@HikariInject protected ArrayList<IHikariStatementProxy> _openStatements;
|
|
|
|
|
@HikariInject protected HikariPool _parentPool;
|
|
|
|
|
|
|
|
|
|
@HikariInject protected boolean _forceClose;
|
|
|
|
@ -109,37 +109,37 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public long _getCreationTime()
|
|
|
|
|
public final long _getCreationTime()
|
|
|
|
|
{
|
|
|
|
|
return _creationTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public long _getLastAccess()
|
|
|
|
|
public final long _getLastAccess()
|
|
|
|
|
{
|
|
|
|
|
return _lastAccess;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public void _markLastAccess()
|
|
|
|
|
public final void _markLastAccess()
|
|
|
|
|
{
|
|
|
|
|
this._lastAccess = System.currentTimeMillis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public void _setParentPool(HikariPool parentPool)
|
|
|
|
|
public final void _setParentPool(HikariPool parentPool)
|
|
|
|
|
{
|
|
|
|
|
this._parentPool = parentPool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public void _unclose()
|
|
|
|
|
public final void _unclose()
|
|
|
|
|
{
|
|
|
|
|
_isClosed.set(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public void _captureStack(long leakDetectionThreshold, Timer scheduler)
|
|
|
|
|
public final void _captureStack(long leakDetectionThreshold, Timer scheduler)
|
|
|
|
|
{
|
|
|
|
|
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
|
|
|
|
|
_stackTrace = new StackTraceElement[trace.length - 4];
|
|
|
|
@ -150,18 +150,19 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public boolean _isBrokenConnection()
|
|
|
|
|
public final boolean _isBrokenConnection()
|
|
|
|
|
{
|
|
|
|
|
return _forceClose;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
public SQLException _checkException(SQLException sqle)
|
|
|
|
|
public final void _checkException(SQLException sqle)
|
|
|
|
|
{
|
|
|
|
|
String sqlState = sqle.getSQLState();
|
|
|
|
|
_forceClose |= (sqlState != null && (sqlState.startsWith("08") || SQL_ERRORS.contains(sqlState)));
|
|
|
|
|
|
|
|
|
|
return sqle;
|
|
|
|
|
if (sqlState != null)
|
|
|
|
|
{
|
|
|
|
|
_forceClose |= sqlState.startsWith("08") | SQL_ERRORS.contains(sqlState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
@ -169,19 +170,15 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
{
|
|
|
|
|
if (_openStatements == null)
|
|
|
|
|
{
|
|
|
|
|
_openStatements = new ArrayList<Statement>(64);
|
|
|
|
|
_openStatements = new ArrayList<IHikariStatementProxy>(64);
|
|
|
|
|
_creationTime = _lastAccess = System.currentTimeMillis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_isClosed == null)
|
|
|
|
|
{
|
|
|
|
|
_isClosed = new ThreadLocal<>();
|
|
|
|
|
_isClosed.set(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
protected void _checkClosed() throws SQLException
|
|
|
|
|
protected final void _checkClosed() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
if (_isClosed.get())
|
|
|
|
|
{
|
|
|
|
@ -190,12 +187,11 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HikariInject
|
|
|
|
|
protected <T extends Statement> T _trackStatement(T statement)
|
|
|
|
|
protected final <T extends IHikariStatementProxy> T _trackStatement(T statement)
|
|
|
|
|
{
|
|
|
|
|
IHikariStatementProxy statementProxy = (IHikariStatementProxy) statement;
|
|
|
|
|
if (statementProxy._getConnectionProxy() == null)
|
|
|
|
|
if (statement._getConnectionProxy() == null)
|
|
|
|
|
{
|
|
|
|
|
statementProxy._setConnectionProxy(this);
|
|
|
|
|
statement._setConnectionProxy(this);
|
|
|
|
|
_openStatements.add(statement);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -209,7 +205,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
@HikariOverride
|
|
|
|
|
public void close() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
if (!_isClosed.get())
|
|
|
|
|
if (!isClosed())
|
|
|
|
|
{
|
|
|
|
|
_isClosed.set(true);
|
|
|
|
|
if (_leakTask != null)
|
|
|
|
@ -229,7 +225,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
@ -251,13 +248,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Statement statement = __createStatement();
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __createStatement();
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -267,13 +265,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Statement statement = __createStatement(resultSetType, resultSetConcurrency);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __createStatement(resultSetType, resultSetConcurrency);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -283,13 +282,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Statement statement = __createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -299,13 +299,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CallableStatement statement = __prepareCall(sql);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareCall(sql);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -315,13 +316,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CallableStatement statement = __prepareCall(sql, resultSetType, resultSetConcurrency);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareCall(sql, resultSetType, resultSetConcurrency);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -331,13 +333,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CallableStatement statement = __prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -347,13 +350,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreparedStatement statement = __prepareStatement(sql);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -363,13 +367,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreparedStatement statement = __prepareStatement(sql, autoGeneratedKeys);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, autoGeneratedKeys);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -379,13 +384,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreparedStatement statement = __prepareStatement(sql, resultSetType, resultSetConcurrency);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, resultSetType, resultSetConcurrency);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -395,13 +401,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreparedStatement statement = __prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -411,13 +418,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreparedStatement statement = __prepareStatement(sql, columnIndexes);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, columnIndexes);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -427,13 +435,14 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
_checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreparedStatement statement = __prepareStatement(sql, columnNames);
|
|
|
|
|
IHikariStatementProxy statement = (IHikariStatementProxy) __prepareStatement(sql, columnNames);
|
|
|
|
|
|
|
|
|
|
return _trackStatement(statement);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -451,7 +460,8 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy, Connect
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
throw _checkException(e);
|
|
|
|
|
_checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|