首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

java.sql.SQLException: ResultSet is closed

2014-01-26 
异常:java.sql.SQLException: ResultSet is closedprivate TheMainFrame frame new TheMainFrame() priv

异常: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;
  }
  }         

热点排行