remove prepStmtHandle = -1 which disables metadata caching, and added fix for BatchTriggerTest
@@ -912,7 +912,6 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
/** Manage re-using cached handles */
private boolean reuseCachedHandle(boolean hasNewTypeDefinitions, boolean discardCurrentCacheItem) {
if (definitionChanged) {
- prepStmtHandle = -1; // so that hasPreparedStatementHandle() also returns false
return false;
}
@@ -2654,6 +2653,11 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
}
}
catch (SQLServerException e) {
+ // if batch exception occurred, throw the initial batchException
+ if (null == batchCommand.batchException) {
+ throw e;
+ }
+
// If the failure was severe enough to close the connection or roll back a
// manual transaction, then propagate the error up as a SQLServerException
// now, rather than continue with the batch.
