求助:关于java.sql.SQLException: Operation not allowed after ResultSet closed的问题

ailianhua ailianhua 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的源代码如下
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.sql.*,java.util.*,com.info.bean.*,com.info.inc.*"%>
<%@ include file="islogin.jsp"%>
<%@ include file="isadmin.jsp"%>
<%
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
PreparedStatement ps2 = null;
ResultSet rs2 = null;
conn=dbconn.getconnection();
comm commhtml = new comm();
String htmlhead ="";
htmlhead = commhtml.HtmlHead("友情提示");
out.println(htmlhead);


%>
<meta http-equiv=refresh content="600;URL=infolist.jsp">
<table align=center width='80%' border=0>
<tr><td>
<div align=left>
<B>回复信息提示</B>:(点击信息标题可以直接进入)
<br>
<%
String StrSql;
StrSql="select * from info_info where guidang=0 and recontent!='' and recontent is not null and isback=0";
StrSql= StrSql + " order by updatetime desc,dateyear desc,yearid desc limit 0,20";
//ps = conn.prepareStatement(StrSql);
ps= conn.prepareStatement(StrSql);
rs = ps.executeQuery();

while (rs.next())
{
%>
<FONT COLOR="#CC0033"><B><%=rs.getString("AdminUnit")%></B></FONT> 对 <a href="recontent.jsp?id=<%=rs.getString("Info_Id")%>"><FONT COLOR="#3333FF"><%=rs.getString("Info_Title")%></FONT></a> 信息做了回复 (<%=rs.getString("Info_Time").substring(0,10)%>)。<br>
<%

}




String StrSql2;
StrSql2="select * from info_info where isback=1 order by updatetime desc,dateyear desc,yearid desc limit 0,20 ";
//ps2 = conn.prepareStatement(StrSql2);
ps2 =conn.prepareStatement(StrSql2);
rs2 = ps2.executeQuery();
int r=0;

%>
<br><br>
<B>退回信息提示</B>:(点击信息标题可以直接进入)
<br>
<%

while (rs2.next())
{
r=1;
%>
<a href="recontent.jsp?id=<%=rs2.getString(1)%>"><FONT COLOR="#3333FF"><%=rs2.getString(9)%></FONT></a> 信息被退回 (<%=rs2.getString(11).substring(0,10)%>)。<br>
<%
}

if(r==1)
{
%>

<EMBED src="/nudge.wav" autostart="true" loop="false" width="0" height="0" hidden=true >
<%
}

%>
</td></tr></table>
</div>
<%
rs2.close();
rs2=null;
ps2.close();
ps2=null;
rs.close();
rs=null;
ps.close();
ps=null;
dbconn.closeconnection();
conn=null;
out.println(commhtml.HtmlTail());
commhtml=null;

目前的问题是,我是读取了两遍数据库,也是使用两个PreparedStatement 和两个ResultSet 来做的,但是它有时候就好使,没有问题,有时候刷新的话 就会出现java.sql.SQLException: Operation not allowed after ResultSet closed的错误,改了好多遍,都不知道错误在哪里,哪位大哥知道啊。愁死了!

十万分感谢啊!
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
ailianhua
Web 开发 81,108 成员 341,721 内容