Index: src/com/mysql/jdbc/ConnectionImpl.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/com/mysql/jdbc/ConnectionImpl.java (revision 1d14b699eff3e6112aaedb1cbe5a151ab81f98f1) +++ src/com/mysql/jdbc/ConnectionImpl.java (revision ) @@ -4286,7 +4286,7 @@ if (getCachePreparedStatements() && pstmt.isPoolable()) { synchronized (this.serverSideStatementCache) { Object oldServerPrepStmt = this.serverSideStatementCache.put(makePreparedStatementCacheKey(pstmt.currentCatalog, pstmt.originalSql), pstmt); - if (oldServerPrepStmt != null) { + if (oldServerPrepStmt != null && oldServerPrepStmt != pstmt) { ((ServerPreparedStatement) oldServerPrepStmt).isCached = false; ((ServerPreparedStatement) oldServerPrepStmt).realClose(true, true); } Index: src/com/mysql/jdbc/ServerPreparedStatement.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/com/mysql/jdbc/ServerPreparedStatement.java (revision 1d14b699eff3e6112aaedb1cbe5a151ab81f98f1) +++ src/com/mysql/jdbc/ServerPreparedStatement.java (revision ) @@ -566,7 +566,6 @@ synchronized (locallyScopedConn.getConnectionMutex()) { if (this.isCached && isPoolable() && !this.isClosed) { clearParameters(); - this.isClosed = true; this.connection.recachePreparedStatement(this); return; }