Example #1
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);
      }
    }
Example #2
0
    /**
     * Find the record with the specified primary keys
     *
     * @return DataPoint or null if no record is found
     */
    public DataPoint find(int id) {
      DataPoint rec = new DataPoint();

      // Create temp object and look in cache for it
      ((DataPoint_base) rec).initialize(id);
      rec = (DataPoint) GenOrmDataSource.getGenOrmConnection().getCachedRecord(rec.getRecordKey());

      java.sql.PreparedStatement genorm_statement = null;
      java.sql.ResultSet genorm_rs = null;

      if (rec == null) {
        try {
          // No cached object so look in db
          genorm_statement = GenOrmDataSource.prepareStatement(SELECT + FROM + KEY_WHERE);
          genorm_statement.setInt(1, id);

          s_logger.debug(genorm_statement.toString());

          genorm_rs = genorm_statement.executeQuery();
          if (genorm_rs.next()) rec = newDataPoint(genorm_rs);
        } catch (java.sql.SQLException sqle) {
          throw new GenOrmException(sqle);
        } finally {
          try {
            if (genorm_rs != null) genorm_rs.close();

            if (genorm_statement != null) genorm_statement.close();
          } catch (java.sql.SQLException sqle2) {
            throw new GenOrmException(sqle2);
          }
        }
      }

      return (rec);
    }
Example #3
0
  // ---------------------------------------------------------------------------
  protected void initialize(java.sql.ResultSet rs) {
    try {
      if (s_logger.isDebug()) {
        java.sql.ResultSetMetaData meta = rs.getMetaData();
        for (int I = 1; I <= meta.getColumnCount(); I++) {
          s_logger.debug("Reading - " + meta.getColumnName(I) + " : " + rs.getString(I));
        }
      }
      m_id.setValue(rs, 1);
      m_metricId.setValue(rs, 2);
      m_timestamp.setValue(rs, 3);
      m_longValue.setValue(rs, 4);
      m_doubleValue.setValue(rs, 5);

    } catch (java.sql.SQLException sqle) {
      throw new GenOrmException(sqle);
    }
  }
Example #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);
      }
    }