updateCounts[i] = EXECUTE_FAILED.intValue();
}
// See if we should return an exception
if (sqlEx != null) {
BatchUpdateException batchEx =
new BatchUpdateException(sqlEx.getMessage(),
sqlEx.getSQLState(),
sqlEx.getErrorCode(),
updateCounts);
// Chain any other exceptions
batchEx.setNextException(sqlEx.getNextException());
throw batchEx;
}
return updateCounts;
} catch (BatchUpdateException ex) {
// If it's a BatchUpdateException let it go
throw ex;
} catch (SQLException ex) {
// An SQLException can only occur while sending the batch
// (getBatchCounts() doesn't throw SQLExceptions), so we have to
// end the batch and return the partial results
// FIXME What should we send here to flush out the batch?
// Come to think of it, is there any circumstance under which this
// could actually happen without the connection getting closed?
// No counts will have been returned either as last packet will not
// have been sent.
throw new BatchUpdateException(ex.getMessage(), ex.getSQLState(),
ex.getErrorCode(), new int[0]);
} finally {
clearBatch();
}
}