Beispiel #1
0
  /**
   * Clob 데이타를 수행한다.
   *
   * @param sql String
   * @param data String
   * @return int
   * @throws SQLException
   */
  public int executeClob(String sql, String data) throws SQLException {
    KJFLog.sql(sql);

    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    int result = 0;

    try {
      conn = this.getConnection();
      ps = conn.prepareStatement(sql);

      CLOB cb = null;

      rs = ps.executeQuery();
      ;

      if (rs.next()) {
        cb = ((OracleResultSet) rs).getCLOB(1);
      }

      long pos = 0; // CLOB 데이타가 insert되는 위치의 offset값을 나타낸다.

      if (cb == null) {
        pos = 1;
      } else {
        pos = cb.length() + 1;
      }

      // CLOB.putString이 buf에 담긴 데이타를 해당 CLOB 컬럼에 update하는
      // 작업을 하게 된다.
      cb.putString(pos, data);

    } catch (SQLException e) {
      System.out.println(e);
      throw e;

    } finally {
      if (rs != null) rs.close();
      if (ps != null) ps.close();
      this.release(conn);
    }

    return result; // Update나 Insert된  row 수
  }