/**
* 更新记录,原子操作,不会commit
* @param sql_id
* @param condition
* @return
* @throws SQLException
*/
public boolean updateBatchSql(String sql, List<List<String>> conditions) throws SQLException {
boolean b = false;
if (sql == null || sql.trim().length() == 0) {
return b;
}
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
//执行sql
try {
conn = handler.getConnection();
pstmt = conn.prepareStatement(sql);
//循环赋值
for (List<String> condition : conditions) {
for (int i = 0; i < condition.size(); i++) {
pstmt.setString(i + 1, condition.get(i));
}
pstmt.addBatch();
}
int[] ret = pstmt.executeBatch();
b = true;
for (int iret : ret) {
if (iret < 0 && iret != PreparedStatement.SUCCESS_NO_INFO) {
b = false;
break;
}
}
} finally {
closeRS(rs, pstmt);
//handler.close();//zxj
}
return b;
}