No operations allowed after statement closed.错误-求助

italucia 2008-01-06 02:31:31
请问一般No operations allowed after statement closed.是什么错误?
报错如下:
java.sql.SQLException: No operations allowed after statement closed.
at com.mysql.jdbc.Statement.checkClosed(Statement.java:277)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:870)
at Display.main(Display.java:92)
源程序
sql="select * From Student";

//read result

try {
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{


String AgentName=rs.getString(1);

System.out.println(AgentName+" ");
}

rs.close();
stmt.close();

}
catch (Exception e){
System.out.println("exceptin in excute the query!");
e.printStackTrace();}



是控制流的错误么?
PS. 关于SQL语句肯定没错。。。
...全文
4043 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
懒得去死 2008-01-06
  • 打赏
  • 举报
回复
http://raibledesigns.com/rd/entry/mysql_problem_no_operations_allowed
italucia 2008-01-06
  • 打赏
  • 举报
回复
问题解决了,就是控制流上有问题,stmt.close()后又循环回去,但没有重新get statement object,把控制流上移下就好了:)

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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