getBatchStatusCode
getBatchStatusCode()
getBatchStatusCode
方法返回
executeBatch
方法执行的一组命令中的最高状态码。
返回值
getBatchStatusCode
方法返回一个整数。
0 - STATUS_SUCCESS - 调用的方法已完成,没有任何错误。
1 - STATUS_WARNING - 调用的方法已完成,且至少有一个警告(但没有错误)。
2 - STATUS_ERROR - 调用的方法未成功完成,并且至少有一个错误。
示例
以下代码样本提供了如何检索
BatchStatusCode
的示例。
// Top level status code is a short cut to determine if there are any
// non-successes in the array of Response objects
if(batchResponse.getBatchStatusCode() == Response.STATUS_SUCCESS)
{
System.out.println("ExecuteBatch ran perfectly!");
}
else if(batchResponse.getBatchStatusCode() == Response.STATUS_WARNING)
{
System.out.println("ExecuteBatch call processed with at least one warning");
}
else
{
System.out.println("ExecuteBatch call processed with at least one error");
}
// Iterate through the array, and print out the message for any non-successes
for(Response response : batchResponse.getResponses())
{
if(response.getStatusCode()!=Response.STATUS_SUCCESS)
{
printDetailMessageOfWarningOrError("executeBatchCommand",
response.getAdvisoryMessages());
}
}
Copyright IBM Corporation 2012. All Rights Reserved.