在线等:关于结果集关闭的问题

weipj007 2004-09-07 11:00:16
String selectstationsql="select StationTable.* from StationTable,SegmentInfoTable,ProjectInfoTable where ProjectInfoTable.projectid=SegmentInfoTable.FatherProjectNum and SegmentInfoTable.segmid=StationTable.segmid and StationTable.Applyflag=2 and SegmentInfoTable.SegMState=1 and (ProjectInfoTable.ProjectState=0 or ProjectInfoTable.ProjectState=1) and StationTable.Applyflag=2 and StationTable.projectid="+projectid+" and StationTable.SegMID="+segmid+"";

rs = dbmanagement.ExecSqlQuery(conn, pstat, selectstationsql, paratype, paravalue);

while (rs.next()) {
StatisticsInfoBean infobean=new StatisticsInfoBean();
String inmemberlist=rs.getString("MemeberList");
String instationid=rs.getString("stationid");
String inprojectid=rs.getString("projectid");
String insegmid=rs.getString("segmid");
String stationbegintime=rs.getString("StationBegTime");
String stationendtime=rs.getString("StationEndTime");

infobean.setMemberlist(inmemberlist);
infobean.setStationId(Integer.parseInt(instationid));
infobean.setProjectid(Integer.parseInt(inprojectid));
infobean.setSegmid(Integer.parseInt(insegmid));
infobean.setBegtime(stationbegintime);
infobean.setEndtime(stationendtime);

stationlist.add(infobean);


if(inmemberlist!=null||!inmemberlist.equals("")){
String inmemberid="";

StringTokenizer st=new StringTokenizer(inmemberlist,",");
while(st.hasMoreTokens()){
String id=st.nextToken();
String selectstra="select * from TimeStrategyTable,projectinfotable,SegmentInfoTable,StationTable,ProjectMemberInfoTable where ProjectMemberInfoTable.memberid=TimeStrategyTable.memberid and TimeStrategyTable.projectid=projectinfotable.projectid and TimeStrategyTable.Subprojectid=SegmentInfoTable.segmid and TimeStrategyTable.StationID=StationTable.stationid and TimeStrategyTable.MemberID="+id+" and TimeStrategyTable.StationID="+instationid+" and StrategyState=3 and StationTable.Applyflag=2 and SegmentInfoTable.SegMState=1 and (ProjectInfoTable.ProjectState=0 or ProjectInfoTable.ProjectState=1) and ProjectMemberInfoTable.InfoState=3";

ArrayList aa=new ArrayList();
ArrayList bb=new ArrayList();
ArrayList aa1=new ArrayList();
ArrayList bb1=new ArrayList();
ArrayList aa2=new ArrayList();
ArrayList bb2=new ArrayList();
rs1 = dbmanagement.ExecSqlQuery(conn, pstat, selectstra,aa,bb);
if(rs1.next()){

String type=rs1.getString("SignType");
String onebegintime=rs1.getString("OnceTimeBeg");
String oneendtime=rs1.getString("OnceTimeEnd");
String morningbegtime=rs1.getString("morningbegtime");
String morningendtime=rs1.getString("morningEndTime");
String afternoonbegtime=rs1.getString("afternoonBegTime");
String afternoonendtime=rs1.getString("afternoonEndTime");

String selectlog="select to_char(SignLogTable.signtime, 'HH24:MI:SS') signtime1,signtime from SignLogTable where MemberId="+id+" and StationId="+instationid+" and ProcessFlag=0";

rs2 = dbmanagement.ExecSqlQuery(conn, pstat, selectlog,aa1,bb1);
while(rs2.next()){

String signtime1=rs2.getString("signtime1");
String signtime=rs2.getString("signtime");

int i=signtime1.compareTo(onebegintime);
int j=signtime1.compareTo(oneendtime);
int k=signtime1.compareTo(morningbegtime);
int l=signtime1.compareTo(morningendtime);
int m=signtime1.compareTo(afternoonbegtime);
int n=signtime1.compareTo(afternoonendtime);
boolean iistrue=false;
boolean jistrue=false;

if(i>=0&&j<0){
iistrue=true;
}
if((k>=0&&l<0)||(m>=0&&n<0)){
jistrue=true;
}
String format="MM/dd/yyyy HH24:MI:SS";
if(type.equals("0")){

if(iistrue){

String insertrecorde="insert into SignRecordTable values("+id+","+inprojectid+","+insegmid+","+instationid+",to_date('"+signtime+"','"+format+"'),1)";
dbmanagement.ExecSqlUpdate(conn, pstat, insertrecorde,aa2,bb2);
if(pstat!=null)
pstat.close();
aa2.clear();
bb2.clear();
}
}
if(type.equals("1")){
if(jistrue){
String insertrecorde="insert into SignRecordTable values("+id+","+inprojectid+","+insegmid+","+instationid+",to_date('"+signtime+"','"+format+"'),0.5)";
dbmanagement.ExecSqlUpdate(conn, pstat, insertrecorde,aa2,bb2);
if(pstat!=null)
pstat.close();
aa2.clear();
bb2.clear();
}
}

}
if(rs2!=null)
rs2.close();
if(pstat!=null)
pstat.close();


String updatesignlog="update signlogtable set SignLogTable.Processflag = 1 where signlogtable.MemberId ="+id+" and StationId="+instationid+"";
dbmanagement.ExecSqlUpdate(conn, pstat, updatesignlog,aa2,bb2);

pstat=null;
aa2.clear();
bb2.clear();

}
if(rs1!=null)
rs1.close();
if(pstat!=null)
pstat.close;
}
}

}
if(rs!=null)
rs.close();
if(pstat!=null)
pstat.close();



大伙帮忙看看我写的这段代码有没有问题。主要是关于结果集关闭。
...全文
107 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianyu807 2004-09-07
  • 打赏
  • 举报
回复
结果集不能嵌套哈!
你可以吧第一个rs存在一数组里面哈!若有3层循环就吧一,二层存在数组里面!
bafver 2004-09-07
  • 打赏
  • 举报
回复
try {

...

} catch() {

...

} finally {

关闭结果集

}

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧