java.sql.SQLException:Operation not allowed after ResultSet closedrs4=stmt1.executeQuery("select * from hr_person where loginCode='"+person.getLoginCode()+"'");if (rs4.next()==false) {rs=stmt1.executeQuery("select * from hr_role where name='"+person.

来源:学生作业帮助网 编辑:作业帮 时间:2024/03/29 06:13:03
java.sql.SQLException:Operation not allowed after ResultSet closedrs4=stmt1.executeQuery(if (rs4.next()==false) {
rs=stmt1.executeQuery("select * from hr_role where name='"+person.getRole().getName()+"'");
while (rs.next()) {
System.out.println(rs.getString("id"));
String sql1 = "insert into hr_person(loginCode,loginPwd,role_id) values ("+"'"+person.getLoginCode()+"'"+","+"'"+person.getLoginPwd()+"'"+","+"'"+rs.getString("id")+"'"+")";
stmt1.executeUpdate(sql1);
rs3=stmt1.executeQuery("select * from hr_person where loginCode='"+person.getLoginCode()+"'");
while (rs3.next()) {
System.out.println(rs3.getString("id"));
String ids=rs3.getString("id");
rs1=stmt1.executeQuery("select * from hr_dept where name='"+person.getDept().getName()+"'");
while (rs1.next()) {
String sql2 = "update hr_person as p set p.dept_id="+"'"+rs1.getString("id")+"'"+"where id="+"'"+ids+"'";
stmt1.executeUpdate(sql2);
rs2=stmt1.executeQuery("select * from hr_resume where name='"+person.getResume().getName()+"'");
while (rs2.next()) {
System.out.println(rs2.getString("id"));
String sql3 = "update hr_person as p set p.resume_id="+"'"+rs2.getString("id")+"'"+"where id="+"'"+ids+"'";
stmt1.executeUpdate(sql3);
}
}
}
}
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}finally{
if (rs2!=null) {
rs2.close();
}
if (rs1!=null) {
rs1.close();
}
if (rs3!=null) {
rs3.close();
}
if (rs!=null) {
rs.close();
}
if (rs4!=null) {
rs4.close();
}
con.close();
con1.close();
}
}

java.sql.SQLException:Operation not allowed after ResultSet closedrs4=stmt1.executeQuery("select * from hr_person where loginCode='"+person.getLoginCode()+"'");if (rs4.next()==false) {rs=stmt1.executeQuery("select * from hr_role where name='"+person.
你还是试试把finally里面的
if (rs1!=null) {
rs1.close();
}
if (rs3!=null) {
rs3.close();
}
if (rs!=null) {
rs.close();
}
if (rs4!=null) {
rs4.close();
}
都去掉,只留一个rs2的.看看行不行.我刚才看到说一个stmt1始终只对应一个结果集,当你操作下面的时候,前面的已经关闭掉了.