make sure the cached handle does not get re-used in case of new typeDefinitions
@@ -923,6 +923,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
if(hasNewTypeDefinitions) {
if (null != cachedPreparedStatementHandle && hasPreparedStatementHandle() && prepStmtHandle == cachedPreparedStatementHandle.getHandle()) {
cachedPreparedStatementHandle.removeReference();
+ cachedPreparedStatementHandle.setIsExplicitlyDiscarded();
}
cachedPreparedStatementHandle = null;
}
@@ -2648,16 +2649,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
// Retry if invalid handle exception.
if (retryBasedOnFailedReuseOfCachedHandle(e, attempt)) {
- // Reset number of batches prepare and reset the prepared type definitions and force eviction of prepared statement cache handle entry
+ //reset number of batches prepare
numBatchesPrepared = numBatchesExecuted;
- paramValues = batchParamValues.get(numBatchesPrepared);
- for (int i = 0; i < paramValues.length; i++)
- batchParam[i] = paramValues[i];
- buildPreparedStrings(batchParam, false);
- PreparedStatementHandle cachedHandle = connection.getCachedPreparedStatementHandle(new Sha1HashKey(preparedSQL, preparedTypeDefinitions));
- if (null != cachedHandle) {
- connection.evictCachedPreparedStatementHandle(cachedHandle);
- }
retry = true;
break;
}
