title: Operation not allowed after ResultSet Closed error Netbeans MySQL Connectivity
body: <p>I am creating a program to rename databases in mysql.
  I have succeeded in everything and it successfully happens. But in the end of my script, its shows an error/exception saying "Operation not allowed after ResultSet closed". I really have no idea why this error appears even after researching about this error.
  Although the full operation is successfully completed and the database is renamed.
  Here is my code-></p>
  
  <pre><code>String x = (String) jComboBox1.getSelectedItem(); //jComboBox1 contains the name of current database selected
  String z = JOptionPane.showInputDialog("Please enter new name for Database"); //Where user enters the name for new database.
  new CustComm().setVisible(false);    //Frame that carries the names of tables.
          try{
          Class.forName("java.sql.DriverManager");
          Connection con = (Connection)
          DriverManager.getConnection("jdbc:mysql://localhost:"+GlobalParams.portvar+"/",""+k,""+j);
          Statement stmnt = (Statement) con.createStatement();
          String query = "use "+x;
          stmnt.executeQuery(query);
          String query2 = "show tables";
          ResultSet rs = stmnt.executeQuery(query2);
          while (rs.next()){ 
          String dname = rs.getString("Tables_in_"+x);
          if(CustComm.jTextArea1.getText().equals("")){
          CustComm.jTextArea1.setText(CustComm.jTextArea1.getText()+dname);
          }
          else{
              CustComm.jTextArea1.setText(CustComm.jTextArea1.getText()+"\n"+dname);
          }
          String y = CustComm.jTextArea1.getText();
          Scanner scanner = new Scanner(y);
  while (scanner.hasNextLine()) {
          String line = scanner.nextLine();
          String query3 = "Create database "+z;
          stmnt.executeUpdate(query3);
          //alter table my_old_db.mytable rename my_new_db.mytable
          String query4 =  "RENAME TABLE "+x+"."+line+" TO "+z+"."+line;
          stmnt.executeUpdate(query4);
          String query5 = "drop database "+x;
          stmnt.executeUpdate(query5);
  }}}
  
      catch(Exception e){
          JOptionPane.showMessageDialog(this,e.getMessage());
      }
  </code></pre>
  
  <p>Please help.</p>