Java.sql.SQLException: After end of result set错误
大家帮我看一下,下面这段代码到底错在哪里啊?老是提示标题上的错误,我都快郁闷死了!
public String update() throws Exception{
String sql="select boardid,boardtype from board";
DBConnect dbc1=new DBConnect(sql);
ResultSet rs=dbc1.executeQuery();
StringBuffer sb=new StringBuffer();
if(!rs.next()){
dbc1.close();
throw new Exception("论坛还没有版面,请先添加版面。");
}
// temprs;
DBConnect dbc=new DBConnect();
String newuser=newuser(dbc);
do{
sql="Select count(announceid) from bbs1 where boardid="+rs.getInt(1);
ResultSet temprs=dbc.executeQuery(sql);
temprs.next();
String tempString=temprs.getString(1);
int allArticle=(tempString==null)?0:temprs.getInt(1);
temprs=dbc.executeQuery("Select count(announceid) from bbs1 where boardid="+rs.getInt(1) +" and parentID=0");
temprs.next();
tempString=temprs.getString(1);
int allTopic=(tempString==null)?0:temprs.getInt(1);
ResultSet ers=dbc.executeQuery("select Max(announceid) from bbs1 where boardid="+rs.getInt(1));
ers.next();
tempString=ers.getString(1);
//int maxID=(tempString==null)?"无":ers.getInt(1);
String userName,dateandtime;
if(tempString==null){
userName="无";
dateandtime=Format.getDateTime();
}
else {
int maxID=ers.getInt(1);
ers=dbc.executeQuery("select username,dateandtime from bbs1 where announceid="+maxID);
ers.next();
userName=ers.getString(1);
dateandtime=ers.getString(2);
}
sql="update board set lastpostuser=?,lastposttime='"+dateandtime+"',lastbbsnum="+allArticle+",lasttopicnum="+allTopic+",TodayNum="+todays(rs.getInt(1),dbc)+" where boardid="+rs.getInt(1);
dbc.prepareStatement(sql);
dbc.setBytes(1,userName.getBytes("GBK"));
dbc.executeUpdate();
sb.append("更新论坛数据成功,"+rs.getString(2)+"共有"+allArticle+"篇贴子,"+allTopic+"篇主题,今日有"+todays(rs.getInt(1),dbc)+"篇帖子。<br>");
}
while(rs.next());
sql="update config set TopicNum="+titlenum(dbc)+",BbsNum="+gettipnum(dbc)+",TodayNum="+alltodays(dbc)+",UserNum="+allusers(dbc)+",lastUser=?";
dbc.prepareStatement(sql);
dbc.setBytes(1,newuser.getBytes("GBK"));
dbc.executeUpdate();
dbc.close();
dbc1.close();
ForumPropertiesManager.resetManager();
return sb.toString();
}