コード例 #1
0
  /**
   * Insert CMN_LABEL_USR Data Bindding JavaBean
   *
   * @param bean CMN_LABEL_USR Data Bindding JavaBean
   * @throws SQLException SQL実行例外
   */
  public void insert(CmnLabelUsrModel bean) throws SQLException {

    PreparedStatement pstmt = null;
    Connection con = null;
    con = getCon();

    try {
      // SQL文
      SqlBuffer sql = new SqlBuffer();
      sql.addSql(" insert ");
      sql.addSql(" into ");
      sql.addSql(" CMN_LABEL_USR(");
      sql.addSql("   LAB_SID,");
      sql.addSql("   LUC_SID,");
      sql.addSql("   LAB_NAME,");
      sql.addSql("   LAB_BIKO,");
      sql.addSql("   LAB_AUID,");
      sql.addSql("   LAB_ADATE,");
      sql.addSql("   LAB_EUID,");
      sql.addSql("   LAB_EDATE,");
      sql.addSql("   LAB_SORT");
      sql.addSql(" )");
      sql.addSql(" values");
      sql.addSql(" (");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?,");
      sql.addSql("   ?");
      sql.addSql(" )");

      pstmt = con.prepareStatement(sql.toSqlString());
      sql.addIntValue(bean.getLabSid());
      sql.addIntValue(bean.getLucSid());
      sql.addStrValue(bean.getLabName());
      sql.addStrValue(bean.getLabBiko());
      sql.addIntValue(bean.getLabAuid());
      sql.addDateValue(bean.getLabAdate());
      sql.addIntValue(bean.getLabEuid());
      sql.addDateValue(bean.getLabEdate());
      sql.addIntValue(bean.getLabSort());
      log__.info(sql.toLogString());
      sql.setParameter(pstmt);
      pstmt.executeUpdate();
    } catch (SQLException e) {
      throw e;
    } finally {
      JDBCUtil.closeStatement(pstmt);
    }
  }
コード例 #2
0
  /**
   * <br>
   * [機 能] ラベルを削除する <br>
   * [解 説] <br>
   * [備 考]
   *
   * @param labSid LAB_SID
   * @return delete count
   * @throws SQLException SQL実行例外
   */
  public int delete(int labSid) throws SQLException {

    PreparedStatement pstmt = null;
    int count = 0;
    Connection con = null;
    con = getCon();

    try {

      CmnLabelUsrModel model = selectOneLabel(labSid);
      ArrayList<Integer> list = selectLabelSort(model.getLabSort(), model.getLucSid());
      // SQL文
      SqlBuffer sql = new SqlBuffer();
      sql.addSql(" delete");
      sql.addSql(" from");
      sql.addSql("   CMN_LABEL_USR");
      sql.addSql(" where ");
      sql.addSql("   LAB_SID=?");

      pstmt = con.prepareStatement(sql.toSqlString());
      sql.addIntValue(labSid);

      log__.info(sql.toLogString());
      sql.setParameter(pstmt);
      count = pstmt.executeUpdate();

      for (int i = 0; i < list.size(); i++) {
        sortArrange(list.get(i));
      }
    } catch (SQLException e) {
      throw e;
    } finally {
      JDBCUtil.closeStatement(pstmt);
    }
    return count;
  }