|
|
|
@ -46,18 +46,19 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
|
|
|
|
|
protected final Connection delegate;
|
|
|
|
|
|
|
|
|
|
private final long creationTime;
|
|
|
|
|
private final FastStatementList openStatements;
|
|
|
|
|
private final HikariPool parentPool;
|
|
|
|
|
private final int defaultIsolationLevel;
|
|
|
|
|
private final boolean defaultAutoCommit;
|
|
|
|
|
private final String defaultCatalog;
|
|
|
|
|
private final AtomicInteger state;
|
|
|
|
|
|
|
|
|
|
private boolean isClosed;
|
|
|
|
|
private boolean forceClose;
|
|
|
|
|
private boolean isTransactionIsolationDirty;
|
|
|
|
|
private boolean isAutoCommitDirty;
|
|
|
|
|
|
|
|
|
|
private final long creationTime;
|
|
|
|
|
private boolean isCatalogDirty;
|
|
|
|
|
private volatile long lastAccess;
|
|
|
|
|
|
|
|
|
|
private StackTraceElement[] leakTrace;
|
|
|
|
@ -65,6 +66,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
|
|
|
|
|
private final int hashCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// static initializer
|
|
|
|
|
static
|
|
|
|
|
{
|
|
|
|
@ -77,12 +79,13 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
SQL_ERRORS.add("JZ0C1"); // Sybase disconnect error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected ConnectionProxy(HikariPool pool, Connection connection, int defaultIsolationLevel, boolean defaultAutoCommit)
|
|
|
|
|
protected ConnectionProxy(HikariPool pool, Connection connection, int defaultIsolationLevel, boolean defaultAutoCommit, String defaultCatalog)
|
|
|
|
|
{
|
|
|
|
|
this.parentPool = pool;
|
|
|
|
|
this.delegate = connection;
|
|
|
|
|
this.defaultIsolationLevel = defaultIsolationLevel;
|
|
|
|
|
this.defaultAutoCommit = defaultAutoCommit;
|
|
|
|
|
this.defaultCatalog = defaultCatalog;
|
|
|
|
|
this.state = new AtomicInteger();
|
|
|
|
|
|
|
|
|
|
this.creationTime = lastAccess = System.currentTimeMillis();
|
|
|
|
@ -173,13 +176,41 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final <T extends Statement> T trackStatement(T statement)
|
|
|
|
|
private <T extends Statement> T trackStatement(T statement)
|
|
|
|
|
{
|
|
|
|
|
openStatements.add(statement);
|
|
|
|
|
|
|
|
|
|
return statement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetConnectionState() throws SQLException
|
|
|
|
|
{
|
|
|
|
|
if (!delegate.getAutoCommit())
|
|
|
|
|
{
|
|
|
|
|
delegate.rollback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isAutoCommitDirty)
|
|
|
|
|
{
|
|
|
|
|
delegate.setAutoCommit(defaultAutoCommit);
|
|
|
|
|
isAutoCommitDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isTransactionIsolationDirty)
|
|
|
|
|
{
|
|
|
|
|
delegate.setTransactionIsolation(defaultIsolationLevel);
|
|
|
|
|
isTransactionIsolationDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isCatalogDirty && defaultCatalog != null)
|
|
|
|
|
{
|
|
|
|
|
delegate.setCatalog(defaultCatalog);
|
|
|
|
|
isCatalogDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delegate.clearWarnings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// IBagManagable Methods
|
|
|
|
|
// **********************************************************************
|
|
|
|
@ -234,24 +265,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
openStatements.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!delegate.getAutoCommit())
|
|
|
|
|
{
|
|
|
|
|
delegate.rollback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isAutoCommitDirty)
|
|
|
|
|
{
|
|
|
|
|
delegate.setAutoCommit(defaultAutoCommit);
|
|
|
|
|
isAutoCommitDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isTransactionIsolationDirty)
|
|
|
|
|
{
|
|
|
|
|
delegate.setTransactionIsolation(defaultIsolationLevel);
|
|
|
|
|
isTransactionIsolationDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delegate.clearWarnings();
|
|
|
|
|
resetConnectionState();
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
@ -486,6 +500,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
/** {@inheritDoc} */
|
|
|
|
|
public final void setAutoCommit(boolean autoCommit) throws SQLException
|
|
|
|
|
{
|
|
|
|
|
checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
delegate.setAutoCommit(autoCommit);
|
|
|
|
@ -501,6 +516,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
/** {@inheritDoc} */
|
|
|
|
|
public final void setTransactionIsolation(int level) throws SQLException
|
|
|
|
|
{
|
|
|
|
|
checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
delegate.setTransactionIsolation(level);
|
|
|
|
@ -513,6 +529,22 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public final void setCatalog(String catalog) throws SQLException
|
|
|
|
|
{
|
|
|
|
|
checkClosed();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
delegate.setCatalog(catalog);
|
|
|
|
|
isCatalogDirty = !catalog.equals(defaultCatalog);
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e)
|
|
|
|
|
{
|
|
|
|
|
checkException(e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */
|
|
|
|
|
public final boolean isWrapperFor(Class<?> iface) throws SQLException
|
|
|
|
|
{
|
|
|
|
|