protected ResultSet getResultSet(Set<String> requestedIds,
        String workflowId, String jobId) throws SQLException {
      db = null;
      ps = null;
      db = connectionFactory.getConnection();
      String fields = getDBFieldString(requestedIds);
      if (requestedIds.contains(JOB_ELAPSED_TIME_PROPERTY_ID)
          && !requestedIds.contains(JOB_SUBMIT_TIME_PROPERTY_ID))
        fields += "," + getDBField(JOB_SUBMIT_TIME_PROPERTY_ID);
      if (jobId == null) {
        ps = db.prepareStatement("SELECT " + fields + " FROM " + JOB_TABLE_NAME
            + " WHERE " + JobFields.WORKFLOWID + " = ?");
        ps.setString(1, workflowId);
      } else {
        ps = db.prepareStatement("SELECT " + fields + " FROM " + JOB_TABLE_NAME
            + " WHERE " + JobFields.JOBID + " = ?");
        ps.setString(1, jobId);
      }
      return ps.executeQuery();
    }
Create a postgres job fetcher that uses a given connection factory.

@param connectionFactory
         a connection factory
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/JobResourceProvider.java