title: ResultSet, null pointer exception and SQLException operation not allowed after ResultSet closed
body: <p>Im new in java and SQL, Im repeating a problem that i don't know how to avoid it:</p>
  
  <p>assume i want to make two executeQuery, one inside the other in the getRequestsFromDB method i make the first executeQuery and in the second method isProfessionalHasThatProfession i make the second executeQuery:</p>
  
  <pre><code> private Vector&lt;ClientRequest&gt; getRequestsFromDB() throws SQLException {
      Vector&lt;ClientRequest&gt; retVal = new Vector&lt;ClientRequest&gt;();
      ResultSet result = null;
      try {
          for (int i=0 ; i&lt;_userBean.getProfession().length ; ++i ){
              result = _statement.executeQuery("SELECT * FROM "+_dbName+"."+CLIENTS_REQUEST_TABLE+" WHERE "+CLIENTS_REQUEST_T_PROFESSION+"='"+_userBean.getProfession()[i]+"'");               
              while(result.next()){ //HERE IN THE SECOND LOOP GETTING NULL EXCEPTION
  
                  if(isProfessionalHasThatProfession(result.getString(CLIENTS_REQUEST_T_PROFESSION))){
                      retVal.add(cr);
                      ClientRequest cr = new ClientRequest
                              (result.getString(CLIENTS_REQUEST_T_CLIENT_ID), 
                              result.getString(CLIENTS_REQUEST_T_CITY),
                              result.getString(CLIENTS_REQUEST_T_DATE),
                              result.getString(CLIENTS_REQUEST_T_PROFESSION));
                  }
              }
          }
      } catch (SQLException ex) {
          throw ex;
      }
      return retVal;
  }
  </code></pre>
  
  <p>the second function:</p>
  
  <pre><code>private boolean isProfessionalHasThatProfession(String profession) throws SQLException {             
      ResultSet result = null;
      try {
          result = _statement.executeQuery("SELECT "+WORKER_PROFESSIONS_T_PROFESSION+" FROM "+_dbName+"."+WORKER_PROFESSIONS_TABLE+" WHERE "+WORKER_PROFESSIONS_T_PROFESSIONAL_ID+"='"+_userBean.getProId()+"'");
          while(result.next()){
              if(result.getString(1).equals(profession)){
                  return true;
              }
          }
      } catch (SQLException ex) {
          throw ex;
      }
      return false;
  }
  </code></pre>
  
  <p>in the second loop im getting a SQLException: "operation not allowed after ResultSet closed", i have tried:
  close in finally the result with result.close() but also i get exception null pointer exception.</p>
  
  <p>i'm really don't know how to deal with that, ideas?
  Thank You!</p>