title: Login restriction
body: <p>First time to try Java.</p>
  
  <pre><code>    String sql = "SELECT * FROM admin";
  
          try {
               Class.forName("com.mysql.jdbc.Driver");
               Connection con= (Connection) 
               DriverManager.getConnection("jdbc:mysql:///mcdc","root","");
               Statement st=con.createStatement();
               rs = st.executeQuery(sql);
               String me = aname.getText();
               String passs = String.valueOf(apass.getPassword());
               String username1=rs.getString("username");
               String password1=rs.getString("password");
               JFrame frm = new JFrame();
  
  
            int tmp=0;
  
           while(tmp &lt; 3) {  
           if(rs.next()){
  
          if((!me.equals(username1)) &amp;&amp; (!passs.equals(password1)))
          {
          JOptionPane.showMessageDialog(frm, "INVALID! ", "Error", JOptionPane.ERROR_MESSAGE);
               aname.setText("");
               apass.setText("");   
          }
          else
          {
          this.setVisible(false);
          new admin_menu().setVisible(true);
          } 
  
          }
  
          } 
          tmp++;
          JOptionPane.showMessageDialog(frm, "You screwed up! ", "Error", JOptionPane.ERROR_MESSAGE);
          }   
          con.close();
      catch(Exception er){
      JFrame frm = new JFrame();
      System.err.println("Exception: " + er.getMessage());
      }
  </code></pre>
  
  <p>Exception: </p>
  
  <blockquote>
    <p>Operation not allowed after ResultSet closed. </p>
  </blockquote>
  
  <p>I'm trying to validate login and this is the error message I got.</p>