예제 #1
0
    /**
     * Returns the reults as an ArrayList of Record objects. The Result set is closed within this
     * call
     *
     * @param maxRows if the result set contains more than this param then an exception is thrown
     */
    public ArrayList<DataPoint> getArrayList(int maxRows) {
      ArrayList<DataPoint> results = new ArrayList<DataPoint>();
      int count = 0;

      try {
        if (m_onFirstResult) {
          count++;
          results.add(factory.newDataPoint(m_resultSet));
        }

        while (m_resultSet.next() && (count < maxRows)) {
          count++;
          results.add(factory.newDataPoint(m_resultSet));
        }

        if (m_resultSet.next())
          throw new GenOrmException(
              "Bound of " + maxRows + " is too small for query [" + m_query + "]");
      } catch (java.sql.SQLException sqle) {
        sqle.printStackTrace();
        throw new GenOrmException(sqle);
      }

      close();
      return (results);
    }
예제 #2
0
    public ResultSet getForMetricId(
        String metricId, java.sql.Timestamp startTime, java.sql.Timestamp endTime) {
      String query =
          SELECT
              + "from data_point this\n				where\n				this.\"metric_id\" = ?\n				and this.\"timestamp\" >= ?\n				and this.\"timestamp\" <= ?\n				order by this.\"timestamp\"";

      java.sql.PreparedStatement genorm_statement = null;

      try {
        genorm_statement = GenOrmDataSource.prepareStatement(query);
        genorm_statement.setString(1, metricId);
        genorm_statement.setTimestamp(2, startTime);
        genorm_statement.setTimestamp(3, endTime);

        s_logger.debug(genorm_statement.toString());

        ResultSet rs = new SQLResultSet(genorm_statement.executeQuery(), query, genorm_statement);

        return (rs);
      } catch (java.sql.SQLException sqle) {
        try {
          if (genorm_statement != null) genorm_statement.close();
        } catch (java.sql.SQLException sqle2) {
        }

        if (s_logger.isDebug()) sqle.printStackTrace();
        throw new GenOrmException(sqle);
      }
    }
예제 #3
0
    /**
     * Returns the reults as an ArrayList of Record objects. The Result set is closed within this
     * call
     */
    public ArrayList<DataPoint> getArrayList() {
      ArrayList<DataPoint> results = new ArrayList<DataPoint>();

      try {
        if (m_onFirstResult) results.add(factory.newDataPoint(m_resultSet));

        while (m_resultSet.next()) results.add(factory.newDataPoint(m_resultSet));
      } catch (java.sql.SQLException sqle) {
        sqle.printStackTrace();
        throw new GenOrmException(sqle);
      }

      close();
      return (results);
    }
예제 #4
0
    public ResultSet getByMetric(String metricId) {
      String query = SELECT + "FROM data_point this WHERE this.\"metric_id\" = ?";

      java.sql.PreparedStatement genorm_statement = null;

      try {
        genorm_statement = GenOrmDataSource.prepareStatement(query);
        genorm_statement.setString(1, metricId);

        s_logger.debug(genorm_statement.toString());

        ResultSet rs = new SQLResultSet(genorm_statement.executeQuery(), query, genorm_statement);

        return (rs);
      } catch (java.sql.SQLException sqle) {
        try {
          if (genorm_statement != null) genorm_statement.close();
        } catch (java.sql.SQLException sqle2) {
        }

        if (s_logger.isDebug()) sqle.printStackTrace();
        throw new GenOrmException(sqle);
      }
    }