bug fixed for pscache, if preparedStatement throw exception, removed from pscache. issue #1052

This commit is contained in:
wenshao
2016-11-24 00:30:11 +08:00
parent b0c791e007
commit 94638ad16f
2 changed files with 6 additions and 4 deletions
@@ -164,7 +164,7 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql.
}
stmt.getPreparedStatementHolder().decrementInUseCount();
if (stmt.isPooled() && holder.isPoolPreparedStatements()) {
if (stmt.isPooled() && holder.isPoolPreparedStatements() && stmt.exceptionCount == 0) {
holder.getStatementPool().put(stmt.getPreparedStatementHolder());
stmt.clearResultSet();
@@ -27,13 +27,14 @@ import java.util.List;
*/
public class DruidPooledStatement extends PoolableWrapper implements Statement {
private final static Log LOG = LogFactory.getLog(DruidPooledStatement.class);
private final static Log LOG = LogFactory.getLog(DruidPooledStatement.class);
private final Statement stmt;
protected DruidPooledConnection conn;
protected List<ResultSet> resultSetTrace;
protected boolean closed = false;
protected int fetchRowPeak = -1;
protected boolean closed = false;
protected int fetchRowPeak = -1;
protected int exceptionCount = 0;
public DruidPooledStatement(DruidPooledConnection conn, Statement stmt){
super(stmt);
@@ -60,6 +61,7 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement {
}
protected SQLException checkException(Throwable error) throws SQLException {
exceptionCount++;
return conn.handleException(error);
}