public void insertMetricValue(long metricRecordID, String metricName,
                                String metricValue) {
    CallableStatement cstmt = null;
    if (metricRecordID < 0 || metricName == null || metricValue == null)
      return;
    try {
      logger.trace("Insert metricRecordId : " + metricRecordID + ", " +
        "metricName : " + metricName + ", metricValue : " + metricValue + ", " +
        "procedure = " + getInsertMetricsProcedureName());
      if (ensureConnection()) {
        String procedureCall =
          String.format("{call %s(?, ?, ?)}", getInsertMetricsProcedureName());
        cstmt = conn.prepareCall(procedureCall);
        cstmt.setLong(1, metricRecordID);
        cstmt.setNString(2, metricName);
        cstmt.setNString(3, metricValue);
        cstmt.execute();
      }
    } catch (Exception e) {
      if (DEBUG)
        logger.info("Error during insertMetricValue call sproc: "
          + e.toString());
      flush();
    } finally {
      if (cstmt != null) {
        try {
          cstmt.close();
        } catch (SQLException se) {
          if (DEBUG)
            logger.info("Error during insertMetricValue close cstmt: "
              + se.toString());
        }
        /*
         * We don't close the connection here because we are likely to be
         * writing
         * more metric values next and it is more efficient to share the
         * connection.
         */
      }
    }
  }
This class stores published metrics to the SQL Server database.
contrib/ambari-scom/metrics-sink/src/main/java/org/apache/hadoop/metrics2/sink/SqlSink.java