code: public List<ScheduledEvent> getScheduledEventList(Date cutofftime) throws SQLException {
          StringBuffer query = new StringBuffer();
          query.append("select EVENT_NAME,CREATE_DT,CONSUME_DT,AUXDATA,REFERENCE,COMMENTS ");
          query.append("from EVENT_INSTANCE ");
          query.append("where STATUS_CD in (");
          query.append(EventInstance.STATUS_SCHEDULED_JOB).append(",");
          query.append(EventInstance.STATUS_INTERNAL_EVENT).append(")");
          ResultSet rs;
          if (cutofftime==null) {
              query.append(" and CONSUME_DT is null");
              rs = db.runSelect(query.toString());
          } else {
              query.append(" and CONSUME_DT < ?");
              rs = db.runSelect(query.toString(), cutofftime);
          }
          List<ScheduledEvent> ret = new ArrayList<ScheduledEvent>();
          while (rs.next()) {
              ScheduledEvent de = new ScheduledEvent();
              de.setName(rs.getString(1));
              de.setCreateTime(rs.getTimestamp(2));
              de.setScheduledTime(rs.getTimestamp(3));
              de.setMessage(rs.getString(4));
              de.setReference(rs.getString(5));
              if (de.getMessage()==null) de.setMessage(rs.getString(6));
              ret.add(de);
          }
          return ret;
      }
docs: Load all internal event and scheduled jobs before cutoff time.
  If cutoff time is null, load only unscheduled events
  @param cutofftime a date or null
  @return
  @throws SQLException