コード例 #1
0
  /**
   * Get the SummarySignalDefinition sequence id num. <br>
   *
   * @param dataBaseName データベース名
   * @param summarySignalDefinition summarySignal
   * @return SummarySignalDefinitionのID
   * @throws SQLException SQL 実行時に例外が発生した場合
   */
  public int selectSequenceNum(String dataBaseName, SummarySignalDefinition summarySignalDefinition)
      throws SQLException {
    int result = 0;
    String summarySignalName = summarySignalDefinition.getSummarySignalName();
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      conn = getConnection(dataBaseName, false);

      String sql =
          "select SUMMARY_SIGNAL_ID from "
              + SUMMARY_SIGNAL_DEFINITION
              + " where SUMMARY_SIGNAL_NAME=?";
      pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, summarySignalName);
      rs = pstmt.executeQuery();
      while (rs.next() == true) {
        int summarySignalId = rs.getInt(1);
        result = summarySignalId;
      }

    } finally {
      SQLUtil.closeResultSet(rs);
      SQLUtil.closeStatement(pstmt);
      SQLUtil.closeConnection(conn);
    }

    return result;
  }
コード例 #2
0
  /**
   * SQL実行計画のレコードを追加します。<br>
   *
   * @param database データベース名
   * @param sqlPlan 挿入するSQL実行計画
   * @throws SQLException SQL 実行時に例外が発生した場合
   */
  public static void insert(final String database, final SqlPlan sqlPlan) throws SQLException {
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      conn = getConnection(database);
      pstmt =
          conn.prepareStatement(
              "insert into "
                  + SQL_PLAN
                  + " (MEASUREMENT_ITEM_NAME, SQL_STATEMENT,"
                  + " EXECUTION_PLAN, GETTING_PLAN_TIME, STACK_TRACE)"
                  + " values (?,?,?,?,?)");
      PreparedStatement delegated = getDelegatingStatement(pstmt);
      // CHECKSTYLE:OFF
      String measurementItemName = sqlPlan.measurementItemName;
      String sqlStatement = sqlPlan.sqlStatement;
      String executionPlan = sqlPlan.executionPlan;
      Timestamp gettingPlanTime = sqlPlan.gettingPlanTime;
      String stackTrace = sqlPlan.stackTrace;

      delegated.setString(1, measurementItemName);
      delegated.setString(2, sqlStatement);
      delegated.setString(3, executionPlan);
      delegated.setTimestamp(4, gettingPlanTime);
      delegated.setString(5, stackTrace);
      // CHECKSTYLE:ON
      delegated.execute();
    } finally {
      SQLUtil.closeResultSet(rs);
      SQLUtil.closeStatement(pstmt);
      SQLUtil.closeConnection(conn);
    }
  }
コード例 #3
0
  /**
   * Insert new Summary Signal Data
   *
   * @param dataBaseName データベース名
   * @param summarySignalDefinition summarySignalDefinition
   * @throws SQLException SQL 実行時に例外が発生した場合
   */
  public static void insert(String dataBaseName, SummarySignalDefinition summarySignalDefinition)
      throws SQLException {
    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
      conn = getConnection(dataBaseName);
      String sql =
          "insert into "
              + SUMMARY_SIGNAL_DEFINITION
              + "(SUMMARY_SIGNAL_NAME, TARGET_SIGNAL_ID,SIGNAL_TYPE, PRIORITY_NO)"
              + " values (?, ?, ?, ?)";
      pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, summarySignalDefinition.getSummarySignalName());

      String signalList = "";
      if (summarySignalDefinition.getSignalList() != null
          && summarySignalDefinition.getSignalList().size() > 0) {
        for (int count = 0; count < summarySignalDefinition.getSignalList().size(); count++) {
          signalList += summarySignalDefinition.getSignalList().get(count);
          if (count != summarySignalDefinition.getSignalList().size() - 1) {
            signalList += ",";
          }
        }
      }

      pstmt.setString(2, signalList);
      pstmt.setInt(SUMMARY_SIGNAL_INDEX1, summarySignalDefinition.getSummarySignalType());
      pstmt.setInt(SUMMARY_SIGNAL_INDEX2, summarySignalDefinition.getPriority());
      pstmt.execute();
    } finally {
      SQLUtil.closeStatement(pstmt);
      SQLUtil.closeConnection(conn);
    }
  }
コード例 #4
0
  /**
   * update the summary signal Information by matching the name<br>
   *
   * @param dataBaseName データベース名
   * @param summarySignalId summary signal のid
   * @param summarySignalDefinitionDto summarySignalのDto
   * @param priorityFlag flag to update all data or not
   * @throws SQLException SQL 実行時に例外が発生した場合
   */
  public void update(
      String dataBaseName,
      long summarySignalId,
      SummarySignalDefinitionDto summarySignalDefinitionDto,
      boolean priorityFlag)
      throws SQLException {

    Connection conn = null;
    PreparedStatement pstmt = null;
    String sql = null;
    try {
      conn = getConnection(dataBaseName);
      if (priorityFlag) {
        sql =
            "update "
                + SUMMARY_SIGNAL_DEFINITION
                + " SET PRIORITY_NO=? where SUMMARY_SIGNAL_NAME=?";
        pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1, summarySignalDefinitionDto.getPriority());
        pstmt.setString(2, summarySignalDefinitionDto.getSummarySignalName());

      } else {
        sql =
            "update "
                + SUMMARY_SIGNAL_DEFINITION
                + " SET SUMMARY_SIGNAL_NAME=?, TARGET_SIGNAL_ID=?,SIGNAL_TYPE=?, PRIORITY_NO=? where SUMMARY_SIGNAL_NAME=?";

        pstmt = conn.prepareStatement(sql);

        pstmt.setString(1, summarySignalDefinitionDto.getSummarySignalName());
        String signalList = "";
        if (summarySignalDefinitionDto.getSignalList() != null
            && summarySignalDefinitionDto.getSignalList().size() > 0) {
          for (int count = 0; count < summarySignalDefinitionDto.getSignalList().size(); count++) {
            signalList += summarySignalDefinitionDto.getSignalList().get(count);
            if (count != summarySignalDefinitionDto.getSignalList().size() - 1) {
              signalList += ",";
            }
          }
        }

        pstmt.setString(2, signalList);
        pstmt.setInt(3, summarySignalDefinitionDto.getSummmarySignalType());
        pstmt.setInt(4, summarySignalDefinitionDto.getPriority());
        pstmt.setString(5, summarySignalDefinitionDto.getSummarySignalName());
      }

      pstmt.executeUpdate();
    } finally {
      SQLUtil.closeStatement(pstmt);
      SQLUtil.closeConnection(conn);
    }
  }
コード例 #5
0
 /**
  * Delete the summary signal data according to the name.<br>
  *
  * @param dataBaseName データベース名
  * @param summarySignalName summarySignalのname
  * @throws SQLException SQL 実行時に例外が発生した場合
  */
 public void delete(String dataBaseName, String summarySignalName) throws SQLException {
   Connection conn = null;
   PreparedStatement pstmt = null;
   try {
     conn = getConnection(dataBaseName, false);
     String sql = "delete from " + SUMMARY_SIGNAL_DEFINITION + " where SUMMARY_SIGNAL_NAME=?";
     pstmt = conn.prepareStatement(sql);
     pstmt.setString(1, summarySignalName);
     pstmt.execute();
   } finally {
     SQLUtil.closeStatement(pstmt);
     SQLUtil.closeConnection(conn);
   }
 }
コード例 #6
0
  /**
   * Get the SummarySignalDefinition List according to the selected name.<br>
   *
   * @param dbName データベース名
   * @param summarySignalName SummarySignal名
   * @return SummarySignalDefinitionのリスト
   * @throws SQLException SQL 実行時に例外が発生した場合
   */
  public List<SummarySignalDefinition> selectByName(String dbName, String summarySignalName)
      throws SQLException {
    List<SummarySignalDefinition> result = new ArrayList<SummarySignalDefinition>();
    List<String> summarySignalList = new ArrayList<String>();
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String summarySignal;
    try {
      conn = getConnection(dbName, false);
      String sql = "select * from " + SUMMARY_SIGNAL_DEFINITION + " where SUMMARY_SIGNAL_NAME=?";
      pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, summarySignalName);
      rs = pstmt.executeQuery();
      while (rs.next() == true) {
        // CHECKSTYLE:OFF
        SummarySignalDefinition summarySignalInfo = new SummarySignalDefinition();
        summarySignalInfo.summarySignalId = rs.getLong(1);
        summarySignalInfo.summarySignalName = rs.getString(2);
        summarySignal = rs.getString(3);
        String[] temp = null;
        temp = summarySignal.split(",");
        for (int index = 0; index < temp.length; index++) {
          summarySignalList.add(temp[index]);
        }
        summarySignalInfo.signalList = summarySignalList;
        summarySignalInfo.summarySignalType = rs.getInt(4);
        summarySignalInfo.priority = rs.getInt(5);
        // CHECKSTYLE:ON
        result.add(summarySignalInfo);
      }
    } finally {
      SQLUtil.closeResultSet(rs);
      SQLUtil.closeStatement(pstmt);
      SQLUtil.closeConnection(conn);
    }

    return result;
  }
コード例 #7
0
  /**
   * Get the SummarySignalDefinition List by ordering the priority.<br>
   *
   * @param dataBaseName データベース名
   * @return SummarySignalDefinitionのリスト
   * @throws SQLException SQL 実行時に例外が発生した場合
   */
  public List<SummarySignalDefinition> selectAllByPriority(String dataBaseName)
      throws SQLException {
    List<SummarySignalDefinition> result = new ArrayList<SummarySignalDefinition>();

    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    String summarySignal;
    try {
      conn = getConnection(dataBaseName, false);
      stmt = conn.createStatement();
      String sql = "select * from " + SUMMARY_SIGNAL_DEFINITION + " ORDER BY PRIORITY_NO DESC";
      rs = stmt.executeQuery(sql);
      while (rs.next() == true) {
        List<String> summarySignalList = new ArrayList<String>();
        // CHECKSTYLE:OFF
        SummarySignalDefinition summarySignalInfo = new SummarySignalDefinition();
        summarySignalInfo.summarySignalId = rs.getLong(1);
        summarySignalInfo.summarySignalName = rs.getString(2);
        summarySignal = rs.getString(3);
        String[] temp = null;
        temp = summarySignal.split(",");
        for (int index = 0; index < temp.length; index++) {
          summarySignalList.add(temp[index]);
        }
        summarySignalInfo.signalList = summarySignalList;
        summarySignalInfo.summarySignalType = rs.getInt(4);
        summarySignalInfo.priority = rs.getInt(5);
        result.add(summarySignalInfo);
      }
    } finally {
      SQLUtil.closeResultSet(rs);
      SQLUtil.closeStatement(stmt);
      SQLUtil.closeConnection(conn);
    }

    return result;
  }