public boolean deleteCustUsers(String ids[]) {
String sql = " DELETE FROM CUSTUSER "
+ " WHERE ID=? ";
Connection conn = null;
PreparedStatement psmt = null;
int count[] = new int[ids.length];
try {
conn = getConnection();
conn.setAutoCommit(false); //넣다가 잘못될수있기떄문에 꺼준다
psmt = conn.prepareStatement(sql);
for(int i = 0; i< ids.length; i++) {
psmt.setString(1, ids[i]);
psmt.addBatch();//누적 축적
}
count = psmt.executeBatch();
conn.commit();
} catch (SQLException e) {
//문제 발생 지역
e.printStackTrace();
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} finally {
//auto commit 켜주기
try {
conn.setAutoCommit(true);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
close(conn, psmt, null);
}
boolean isS = true;
for (int i = 0; i < count.length; i++) {
if(count[i] != -2) { // -2 -> 정상종료
isS = false;
break;
}
}
return isS;
}