异常:java.sql.SQLException: ResultSet is closed
private TheMainFrame frame = new TheMainFrame();
private Boolean flag = false;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
//DbCon是连接数据库的类,getConnection()是其中得到连接的方法
Connection con = new DbCon().getConnection();
Statement stm = con.createStatement();
ResultSet rs=stm.executeQuery( "select 用户名,密码 from admin ");
while(rs.next())
{
String name = rs.getString(1).trim();
String pass = rs.getString(2).trim();
if (txtUser.getText().equals(name))
{
if( String.copyValueOf(txtPwd.getPassword()).equals(pass))
{
flag = true;
frame.setVisible(true);
dispose();
}
else
{
JOptionPane.showMessageDialog(this, "密码错误 ");
txtPwd.setText( " ");
txtPwd.requestFocus();
return;
}
}