PreparedStatement ps = conn.prepareStatement(sql);
ps.addBatch();
try{
int[] count = ps.executeBatch();//数组的length代表所有执行成功的记录
}catch(BatchUpdateException e){
int[] count = e.getUpdateCounts(); //数组中元素大于等于0的代表执行成功的记录,小于0为执行失败的记录
}
PreparedStatement ps = conn.prepareStatement(sql);
ps.addBatch();
try{
int[] count = ps.executeBatch();//数组的length代表所有执行成功的记录
}catch(BatchUpdateException e){
int[] count = e.getUpdateCounts(); //数组中元素大于等于0的代表执行成功的记录,小于0为执行失败的记录
}
本文标题:PreparedStatement下批量执行返回结果问题
本文链接:https://www.haomeiwen.com/subject/fwgxjctx.html
网友评论