mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
remove the statement from pool while it threw an exception
While the pooled PreparedStatement threw an exception, remove it from
the pool, and then close it.
The commit 94638ad didn’t fix issue #1498 . Try this one.
This commit is contained in:
@@ -173,6 +173,12 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql.
|
||||
stmt.getPreparedStatementHolder().setFetchRowPeak(stmt.getFetchRowPeak());
|
||||
|
||||
stmt.setClosed(true); // soft set close
|
||||
} else if (stmt.isPooled() && holder.isPoolPreparedStatements()) {
|
||||
// the PreparedStatement threw an exception
|
||||
stmt.clearResultSet();
|
||||
holder.removeTrace(stmt);
|
||||
|
||||
holder.getStatementPool().remove(stmt.getPreparedStatementHolder());
|
||||
} else {
|
||||
try {
|
||||
//Connection behind the statement may be in invalid state, which will throw a SQLException.
|
||||
|
||||
@@ -72,6 +72,14 @@ public class PreparedStatementPool {
|
||||
return holder;
|
||||
}
|
||||
|
||||
public void remove(PreparedStatementHolder stmtHolder) throws SQLException {
|
||||
if (stmtHolder == null) {
|
||||
return;
|
||||
}
|
||||
map.remove(stmtHolder.key, stmtHolder);
|
||||
closeRemovedStatement(stmtHolder);
|
||||
}
|
||||
|
||||
public void put(PreparedStatementHolder stmtHolder) throws SQLException {
|
||||
PreparedStatement stmt = stmtHolder.statement;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user