Ejemplo n.º 1
0
  public int delete(ValueObject obj) throws SQLException {

    if ((obj instanceof PT_BBS_COM_FILESEntity) == false) {
      throw new SQLException("DAO 에러(1): PT_BBS_COM_FILES : delete() ");
    }
    PT_BBS_COM_FILESEntity entity = (PT_BBS_COM_FILESEntity) obj;

    Connection conn = null;
    PreparedStatement ps = null;
    int result = 0;

    StringBuffer sb = new StringBuffer();
    sb.append("delete from PT_BBS_COM_FILES  where  1=1")
        .append(" and SYS_FILE_NAME = ")
        .append(toDB(entity.getSYS_FILE_NAME()));

    KJFLog.sql(sb.toString());

    try {

      conn = this.getConnection();
      ps = conn.prepareStatement(sb.toString());

      result = ps.executeUpdate();

    } catch (SQLException e) {
      throw e;
    } finally {
      if (ps != null) ps.close();
      this.release(conn);
    }

    return result;
  }
Ejemplo n.º 2
0
  public int update(ValueObject obj) throws SQLException {

    if ((obj instanceof PT_BBS_COM_FILESEntity) == false) {
      throw new SQLException("DAO 에러(1): PT_BBS_COM_FILES : update() ");
    }
    PT_BBS_COM_FILESEntity entity = (PT_BBS_COM_FILESEntity) obj;

    Connection conn = null;
    PreparedStatement ps = null;
    int result = 0;

    StringBuffer sb = new StringBuffer();
    sb.append("update PT_BBS_COM_FILES  set ")
        .append("CT_ID = ")
        .append(toDB(entity.getCT_ID()))
        .append(",")
        .append("BOARD_SEQ = ")
        .append(toDB(entity.getBOARD_SEQ()))
        .append(",")
        .append("FILE_REAL_NAME = ")
        .append(toDB(entity.getFILE_REAL_NAME()))
        .append(",")
        .append("FILE_SIZE = ")
        .append(toDB(entity.getFILE_SIZE()))
        .append(",")
        .append("UPD_DT = ")
        .append(toDB(entity.getUPD_DT()))
        .append(",")
        .append("DOWN_HIT = ")
        .append(toDB(entity.getDOWN_HIT()))
        .append(" where  1=1 ");

    sb.append(" and SYS_FILE_NAME = ").append(toDB(entity.getSYS_FILE_NAME()));

    KJFLog.sql(sb.toString());

    try {

      conn = this.getConnection();
      ps = conn.prepareStatement(sb.toString());

      int i = 1;

      result = ps.executeUpdate();

    } catch (SQLException e) {
      throw e;
    } finally {
      if (ps != null) ps.close();
      this.release(conn);
    }

    return result;
  }
Ejemplo n.º 3
0
  ///////////////////////////////////////////////////////////////////////////////////
  // 특정필드를 제외한 전체 필드를 수정한다.
  public int updateExcludeOnly(ValueObject obj, String[] fields) throws SQLException {

    fields = KJFUtil.getDifferenceOfSets(default_fields, fields);

    if ((obj instanceof PT_BBS_COM_FILESEntity) == false) {
      throw new SQLException("DAO 에러(1): PT_BBS_COM_FILES : updateModifiedOnly() ");
    }
    PT_BBS_COM_FILESEntity entity = (PT_BBS_COM_FILESEntity) obj;

    HashMap clobs = new HashMap();

    Connection conn = null;
    PreparedStatement ps = null;
    int result = 0;

    if (fields == null) throw new SQLException("Field Name can not be Null");

    StringBuffer setString = new StringBuffer();
    boolean flag = false;
    for (int i = 0; i < fields.length; i++) {
      if (fields[i] == null) throw new SQLException("Field Name can not be Null");
      if (default_update_field.containsKey(fields[i]) == false) {
        if (flag) setString.append(",");
        flag = true;
        if (clobs.containsKey(fields[i])) {
          setString.append(fields[i]).append("=?");
        } else {
          setString.append(fields[i]).append("=").append(toDB(entity.getByName(fields[i])));
        }
      }
    }
    if (flag = false) throw new SQLException("Nothing to update");

    StringBuffer sb = new StringBuffer();
    sb.append("update PT_BBS_COM_FILES  set ").append(setString.toString()).append(" where  1=1 ");

    sb.append(" and SYS_FILE_NAME = ").append(toDB(entity.getSYS_FILE_NAME()));

    KJFLog.sql(sb.toString());

    try {

      conn = this.getConnection();
      ps = conn.prepareStatement(sb.toString());

      int k = 1;
      for (int i = 0; i < fields.length; i++) {
        if (clobs.containsKey(fields[i])) {

          ps.setString(k++, (entity.getByName(fields[i])).toString());
        }
      }

      result = ps.executeUpdate();

    } catch (SQLException e) {
      throw e;
    } finally {
      if (ps != null) ps.close();
      this.release(conn);
    }

    return result;
  }