67,512
社区成员
发帖
与我相关
我的任务
分享
public boolean delUser(int[] id) {
boolean flag = false;
String sql = "delete from userInfo where userId=?";
conn = base.getConnection();
PreparedStatement pst = null;
try {
pst = conn.prepareStatement(sql);
for (int i = 0; i < id.length; i++) {
pst.setInt(1, id[i]);
// 使用批处理
pst.addBatch();
}
// 执行批处理
int[] result = pst.executeBatch();
if (result[0] > 0) {
flag = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
base.free(conn, pst, null);
} catch (SQLException e) {
e.printStackTrace();
}
}
return flag;
}