mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
removeAbandanded skip running connections
This commit is contained in:
@@ -35,7 +35,7 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
private final static Log LOG = LogFactory.getLog(DruidPooledStatement.class);
|
||||
|
||||
private final Statement stmt;
|
||||
protected DruidPooledConnection conn;
|
||||
protected DruidPooledConnection conn;
|
||||
protected final List<ResultSet> resultSetTrace = new ArrayList<ResultSet>();
|
||||
protected boolean closed = false;
|
||||
protected int fetchRowPeak = -1;
|
||||
@@ -96,6 +96,10 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
this.getPoolableConnection().getConnectionHolder().getDataSource().incrementExecuteCount();
|
||||
}
|
||||
|
||||
protected void transactionRecord(String sql) throws SQLException {
|
||||
conn.transactionRecord(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ResultSet executeQuery(String sql) throws SQLException {
|
||||
checkOpen();
|
||||
@@ -103,6 +107,7 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
|
||||
@@ -112,13 +117,11 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
return poolableResultSet;
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
protected void transactionRecord(String sql) throws SQLException {
|
||||
conn.transactionRecord(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int executeUpdate(String sql) throws SQLException {
|
||||
checkOpen();
|
||||
@@ -126,20 +129,115 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.executeUpdate(sql);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
if (!this.closed) {
|
||||
clearResultSet();
|
||||
stmt.close();
|
||||
this.closed = true;
|
||||
conn.getConnectionHolder().removeTrace(this);
|
||||
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.executeUpdate(sql, autoGeneratedKeys);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int executeUpdate(String sql, int columnIndexes[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.executeUpdate(sql, columnIndexes);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int executeUpdate(String sql, String columnNames[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.executeUpdate(sql, columnNames);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.execute(sql, autoGeneratedKeys);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql, int columnIndexes[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.execute(sql, columnIndexes);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql, String columnNames[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.execute(sql, columnNames);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +251,16 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
if (!this.closed) {
|
||||
clearResultSet();
|
||||
stmt.close();
|
||||
this.closed = true;
|
||||
conn.getConnectionHolder().removeTrace(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxFieldSize(int max) throws SQLException {
|
||||
@@ -415,10 +523,13 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
|
||||
incrementExecuteCount();
|
||||
|
||||
conn.beforeExecute();
|
||||
try {
|
||||
return stmt.executeBatch();
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
} finally {
|
||||
conn.afterExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,90 +568,6 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
return stmt.executeUpdate(sql, autoGeneratedKeys);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int executeUpdate(String sql, int columnIndexes[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
return stmt.executeUpdate(sql, columnIndexes);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int executeUpdate(String sql, String columnNames[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
return stmt.executeUpdate(sql, columnNames);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
return stmt.execute(sql, autoGeneratedKeys);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql, int columnIndexes[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
return stmt.execute(sql, columnIndexes);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(String sql, String columnNames[]) throws SQLException {
|
||||
checkOpen();
|
||||
|
||||
incrementExecuteCount();
|
||||
transactionRecord(sql);
|
||||
|
||||
try {
|
||||
return stmt.execute(sql, columnNames);
|
||||
} catch (Throwable t) {
|
||||
throw checkException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getResultSetHoldability() throws SQLException {
|
||||
checkOpen();
|
||||
@@ -582,7 +609,7 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
public boolean isCloseOnCompletion() throws SQLException {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (iface == Statement.class) {
|
||||
@@ -591,7 +618,7 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
|
||||
}
|
||||
return (T) stmt;
|
||||
}
|
||||
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user