我开发了简单的Web服务,使用JDeveloper从oracle数据库中提取数据,数据按预期返回,当我使用“从表名中删除where condition”手动删除数据库时出现问题,并通过Web服务发出新请求结果在删除之前返回。
这是从db
读取的方法 private int GetStudnetRequests(int STID,int SEMID) {
ResultSet rs = null;
int TotalReq = 0;
PreparedStatement prepStmt = null;
try {
String query = "SELECT count(*) from REQUESTS where ID=? and SEM=? ";
prepStmt = connection.prepareStatement(query);
prepStmt.setInt(1, STID);
prepStmt.setInt(2, SEMID);
rs = prepStmt.executeQuery();
while (rs.next()) {
TotalReq = rs.getInt(1);
System.out.println("Number of Request" + TotalReq);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (prepStmt != null)
prepStmt.close();
closeDB();
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return TotalReq;
}
我从数据库中删除后,TotalReq没有改变,它保持给我最后一个值
这里我怎么称呼这个方法
if ((GetStudnetRequests(STID,SEMID) <= NumofRequests)) {
output = BuildOutput(true, "success");
InsertRequest(STID, COURSEID, SEMID); // create request on suc
}