process all batch first, then throw batch exception is there is one, otherwise throw sql server exception
@@ -2561,6 +2561,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
definitionChanged = false;
TDSWriter tdsWriter = null;
+ try {
while (numBatchesExecuted < numBatches) {
// Fill in the parameter values for this batch
Parameter paramValues[] = batchParamValues.get(numBatchesPrepared);
@@ -2636,8 +2637,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
// exception for this result. The exception gets caught immediately below and
// translated into (or added to) a BatchUpdateException.
if (null != resultSet) {
- SQLServerException.makeFromDriverError(connection, this, SQLServerException.getErrString("R_resultsetGeneratedForUpdate"),
- null, false);
+ SQLServerException.makeFromDriverError(connection, this,
+ SQLServerException.getErrString("R_resultsetGeneratedForUpdate"), null, false);
}
}
catch (SQLServerException e) {
@@ -2652,16 +2653,6 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
updateCount = Statement.EXECUTE_FAILED;
if (null == batchCommand.batchException)
batchCommand.batchException = e;
-
- // throw the initial batchException
- if (null != batchCommand.batchException) {
- if (numBatchesExecuted < numBatchesPrepared) {
- continue;
- }
- else {
- throw e;
- }
- }
}
// In batch execution, we have a special update count
@@ -2678,6 +2669,16 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
}
}
}
+ catch (SQLServerException e) {
+ // throw the initial batchException
+ if (null != batchCommand.batchException) {
+ throw batchCommand.batchException;
+ }
+ else {
+ throw e;
+ }
+ }
+ }
public final void setCharacterStream(int parameterIndex,
Reader reader) throws SQLException {
