title: Returning a ResultSet
body: <p>I am trying to create a method from where I can query my database and retrieve a whole table.</p>
  
  <p>Currently, it works just fine if I use the data <em>inside</em> the method. However, I want the method to return the results.</p>
  
  <p>I'm getting a <code>java.sql.SQLException: Operation not allowed after ResultSet closed</code> on the current code.</p>
  
  <p>How can I achieve this?</p>
  
  <pre><code>public ResultSet select() {
  
      con = null;
      st = null;
      rs = null;
  
      try {
          con = DriverManager.getConnection(url, user, password);
          st = con.createStatement();
  
          rs = st.executeQuery("SELECT * FROM biler");
          /*
          if (rs.next()) {
              System.out.println(rs.getString("model"));
          }*/
  
      } catch (SQLException ex) {
          Logger lgr = Logger.getLogger(MySQL.class.getName());
          lgr.log(Level.SEVERE, ex.getMessage(), ex);
  
      } finally {
          try {
              if (rs != null) {
                  rs.close();
              }
              if (st != null) {
                  st.close();
              }
              if (con != null) {
                  con.close();
              }
  
          } catch (SQLException ex) {
              Logger lgr = Logger.getLogger(MySQL.class.getName());
              lgr.log(Level.WARNING, ex.getMessage(), ex);
          }
      }
  
      return rs;
  }
  </code></pre>