weblogic下在Oracle中存储clob类型一例

来源:互联网 发布:淘宝上pc端是什么意思 编辑:程序博客网 时间:2024/06/07 21:08

String sql = "select t.FILE_INFO from T_FILE_DB_DETAIL t where t.id= "
      + fileDBUpDownDetail.getId() + " for update";
    rs = stmt.executeQuery(sql);
    if (rs.next()) {
     // 在weblogic下部署时,需要更改为Bea WebLogic BLOB格式
//     weblogic.jdbc.vendor.oracle.OracleThinBlob blob = (weblogic.jdbc.vendor.oracle.OracleThinBlob) rs
//       .getBlob(1);
     BLOB blob = (BLOB) rs.getBlob(1);

     if (blob != null) {
      out = blob.getBinaryOutputStream();
      byte[] buf = new byte[8192];// 8K 缓存
      int len;
      while ((len = fileInputStream.read(buf)) > 0) {
       if (out != null) {
        out.write(buf, 0, len);
        out.flush();
       }
      }
     }
    }