No operations allowed after statement closed.错误-求助
请问一般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语句肯定没错。。。