Operation not allowed after ResultSet closed
public class shanchuB implements ActionListener{JTextField t;
public shanchuB(JTextField t) {
this.t=t;
}
public void actionPerformed(ActionEvent e) {
String shnumber=t.getText();
if(shnumber.equals(""))
JOptionPane.showMessageDialog(null, "请填写学号!");
else {
//定义mysql数据库驱动的类mysql.jdbc.Driver
String driverClass1="com.mysql.jdbc.Driver";
//定义连的mysql的URL接
String url1="jdbc:mysql://localhost:3306/grade";
String username11="root";
//密码
String password11="2827391563";
//定义Connection连接
Connection conn1=null;
Statement stmt1=null;
try {
//注册数据库的驱动程序
Class.forName(driverClass1);
conn1 = DriverManager.getConnection(url1,username11,password11);
stmt1 = conn1.createStatement();
String sql1="SELECT * FROM managedata.student;";
String sql2="DELETE FROM `managedata`.`student` WHERE studentnumber='"+shnumber+"'";
ResultSet rs1=stmt1.executeQuery(sql1);
while(rs1.next()){
String tnumber=rs1.getString("studentnumber");
if(tnumber.equals(shnumber)) {
stmt1.executeUpdate(sql2);
JOptionPane.showMessageDialog(null, "删除成功!");
}
}} catch (Exception e1) {
e1.printStackTrace();
}finally {
try {
if(stmt1!=null) {
stmt1.close();
}
if(conn1!=null)
{
conn1.close();
}
}catch(Exception e1) {
e1.printStackTrace();
}
}
}
}
}
怎么解决。求大神指教,谢谢!