title: -> java.sql.SQLException: Exhausted Resultset
body: <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  
      if (evt.getSource() == jButton1) {
  
          String ab = jTextField1.getText();
          String bc = jPasswordField1.getText().toString();
          String cd = jTextField2.getText();
          String de = jTextField3.getText();
          PreparedStatement ps1 = null;
          PreparedStatement ps = null;
          ResultSet rs = null;
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "hr");
              ps = c.prepareStatement("Select User_Name from AdminLogin where Password =?");
              ps.setString(1, bc);
  
              rs = ps.executeQuery();
              rs.next();
  
              if (ab.equals(rs.getString(1))) {
  
                  ps1 = c.prepareStatement("Update AdminLogin SET Date1=?,Time=? WHERE Password=?");
                  ps1.setString(1, cd);
                  ps1.setString(2, de);
                  ps1.setString(3, bc);
                  int e = ps1.executeUpdate();
                  JOptionPane.showMessageDialog(this, "Welcome", "Logged In", JOptionPane.INFORMATION_MESSAGE);
                  //MainMenuAAI mainMenuAAI = new MainMenuAAI();
                  //setVisible(false);}
              } else if (!(ab.equals(rs.getString(1)))) {
                  JOptionPane.showMessageDialog(this, "&lt;html&gt;YOU ARE NOT A&lt;br&gt;ADMIN&lt;/br&gt;&lt;/html&gt;", "ERROR", JOptionPane.ERROR_MESSAGE);
                  //AdminLogin admin=new AdminLogin();
                  //setVisible(false);
              }
  
              c.close();
          } catch (Exception e) {
  
              System.out.println(e);
          }
      }// TODO add your handling code here:
  }
  </code></pre>
  
  <p>Everything is working fine in the code. It is executing the code inside</p>
  
  <pre><code>if(ab.equals(rs.getString(1)))
  </code></pre>
  
  <p>and showing "Welcome" but not d one inside</p>
  
  <pre><code>if(!(ab.equals(rs.getString(1))))
  </code></pre>
  
  <p>Whenever I enter wrong username or password it shows the error</p>
  
  <p>java.sql.SQLException: Exhausted Resultset</p>