title: Operation not allowed after ResultSet closed
body: <p>Allright been trying to figure this out the last 2 days.</p>
  
  <pre><code>Statement statement = con.createStatement();
                          String query = "SELECT * FROM sell";
                          ResultSet rs = query(query);
                          while (rs.next()){//&lt;--- I get there operation error here
  </code></pre>
  
  <p>This is the query method.</p>
  
  <pre><code>    public static ResultSet query(String s) throws SQLException {
          try {
              if (s.toLowerCase().startsWith("select")) {
                  if(stm == null) {
                      createConnection();
                  }
                  ResultSet rs = stm.executeQuery(s);
                  return rs;
              } else {
                  if(stm == null) {
                      createConnection();
                  }
                  stm.executeUpdate(s);
              }
              return null;
          } catch (Exception e) {
              e.printStackTrace();
              con = null;
              stm = null;
          }
          return null;
      }
  </code></pre>
  
  <p>How can I fix this error?</p>