public  ArrayList<HashMap<String, String>> executeQuery(ArrayList<String> fields,String clause, PartnerConnection connection) {
        
        ArrayList<HashMap<String, String>> retMap = new ArrayList<HashMap<String, String>>();
        
        connection.setQueryOptions(250);
        
        try {
            String query = "SELECT ";
            Integer counter = 1;
            
            for(String field : fields){
                if(counter < fields.size())
                    query += field + " , ";
                else
                    query += field + " ";
                counter++;
            }
            
            query += clause;
            
          boolean done = false;  
          // query for the 5 newest contacts      
          QueryResult queryResults = connection.query(query);
          
          while (!done) {
              
            if (queryResults.getSize() > 0) {
              for (SObject s: queryResults.getRecords()) {
                  
                  HashMap<String,String> tempMap = new HashMap<String,String>();
                          
                  for(String field : fields){
                      if(field.toUpperCase().equals("ID")){
                          tempMap.put(field.toUpperCase(), s.getId());
                      }else{
                          tempMap.put(field.toUpperCase(), s.getField(field).toString());
                      }
                      
                  }  
                  
                  retMap.add(tempMap);
              }
              
              if (queryResults.isDone()) {
                    done = true;
                } else {
                    queryResults = connection.queryMore(queryResults.getQueryLocator());
                }
            }
              
          }
         

        } catch (Exception e) {
          e.printStackTrace();
        }    
        
        return retMap;
  }