日期:2014-05-20  浏览次数:20661 次

求高手指教,这段代码有没有错。。。
for (int k = 0; k < classCodeList.size(); k++) {
// 根据ClassCode,获取对应的班级ID
String hql = "select " + classRecordId + " from " + classtbName + " where " + classCode + "='"
+ classCodeList.get(k) + "' ";
preparedstatement = dataOperate.getStatementSystem(hql);
rs = preparedstatement.executeQuery();
while (rs.next()) {
delclassRecordIDList.add(rs.getInt(1));
}
}

for (int l = 0; l < userCodeList.size(); l++) {

// 根据RequestCode,获取对应的老师ID
String hql1 = "select * from " + tblName + " where " + userInfoCode + "='"
+ userCodeList.get(l) + "'";
preparedstatement = dataOperate.getStatementSystem(hql1);
rs = preparedstatement.executeQuery();
while (rs.next()) {
userRecordIDList.add(rs.getInt(1));
}
}

for (int w = 0; w < delclassRecordIDList.size(); w++) {
for (int q = 0; q < userRecordIDList.size(); q++) {
// 根据老师ID获取老师所有管理的中间表的关系ID
String seleSql = "select * from " + urctbName + "";
seleSql += " where " + user_ID + " = " + userRecordIDList.get(q) + "";
preparedstatement = dataOperate.getStatementSystem(seleSql);
rs = preparedstatement.executeQuery();
while (rs.next()) {
urcRecordIDList.add(rs.getInt(1));// 将老师所有的关系放如LIST中
}

// 根据老师ID和班级ID,得到中间表对应的RECORD_ID
String seleS = "select * from " + urctbName + "";
seleS += " where " + class_ID + "=" + delclassRecordIDList.get(w) + "";
seleS += " and " + user_ID + " = " + userRecordIDList.get(q) + "";
preparedstatement = dataOperate.getStatementSystem(seleS);
rs = preparedstatement.executeQuery();
while (rs.next()) {
urcRecordIDListByUser.add(rs.getInt(1));
}

if (insterts.size() == 0) {
if (urcRecordIDList.get(w).equals(urcRecordIDListByUser.get(q))) {
System.out.println("ID同等,不进行操作!!!");
} else {
System.out.println("要删除的" + sysInfo.getName());
String delSql1 = "delete " + urctbName + " where " + recordId + " = "
+ urcRecordIDList.get(w) + "";
preparedstatement = dataOperate.getStatementSystem(delSql1);
preparedstatement.execute();
preparedstatement.getConnection().commit();
}

} else {
String delSql = "delete " + urctbName + " where " + class_ID + " = "
+ delclassRecordIDList.get(w) + " and " + user_ID + " = "
+ userRecordIDList.get(q) + "";
preparedstatement = dataOperate.getStatementSystem(delSql);
preparedstatement.execute();
preparedstatement.getConnection().commit();
}
}
}

------解决方案--------------------
自己跑下就知道有没有错了~~汗死~
------解决方案--------------------
自己运行一遍,出结果了再说