我写的程序功能对数据库的操作都实现了,不过SQL会抛出一个异常ResultSet is closed,怎么也解决不了。..有人能帮忙下不?
java.sql.SQLException: ResultSet is closed
public void jButton1_actionPerformed(ActionEvent e){
String a = jText1.getText();
String x,y,z;
char [] b;
char [] c;
char [] d;
b = jPasswordText1.getPassword();
c = jPasswordText2.getPassword();
d = jPasswordText3.getPassword();
x = new String(b);
y = new String(c);
z = new String(d);
shujuku shuju2 = new shujuku();
try {
String Str = "SELECT count(*) FROM Login where LoginName = '"+ a +"' AND Password = '"+ x +"'";
String Str2 = "UPDATE Login SET Password = '" + y +
"' WHERE LoginName = '" + a + "'";
ResultSet rs = shuju2.s.executeQuery(Str);
if (y.equals(z) && a.length() > 0 && x.length()>=6 && y.length()>=6 && z.length()>=6)
{
while (rs.next()) {
int f;
f = rs.getInt(1);
if (f < 1) {
JOptionPane.showMessageDialog(this, "用户名或密码不正确\n请重新输入",
"注意",
JOptionPane.PLAIN_MESSAGE, null);
jText1.requestFocus();
jText1.setText(null);
jPasswordText1.setText(null);
jPasswordText2.setText(null);
jPasswordText3.setText(null);
} else {
int rowcount = shuju2.s.executeUpdate(Str2);
if (rowcount == 1) {
JOptionPane.showMessageDialog(this, "修改成功",
"消息",
JOptionPane.INFORMATION_MESSAGE, null);
this.dispose();
}
}
}
}
else {
JOptionPane.showMessageDialog(this,
"1.用户名不能为空\n2.二次输入不一致\n3.旧密码和新密码必须大于6位\n请重新输入",
"注意",
JOptionPane.PLAIN_MESSAGE, null);
jText1.requestFocus();
jText1.setText(null);
jPasswordText1.setText(null);
jPasswordText2.setText(null);
jPasswordText3.setText(null);
}
rs.close();
shuju2.s.close();
shuju2.con.close();
}
catch (SQLException ce) {
System.out.println(ce);
}
//finally{}
}