Oracle clob处理

for (int i=0;i<noticeResult.getResult().size();i++) {
CLOB clob = (CLOB) noticeResult.getResult().get(i).get("NOTICE_CONTENT");
String  content = "";
    try {
    if (clob != null && clob.length() != 0) {
content = clob.getSubString((long) 1, (int) clob.length());
content = this.Clob2String(clob);
     }
} catch (SQLException e) {
e.printStackTrace();
}
      
System.out.println("NOTICE_CONTENT:"+content);

}


private String Clob2String(CLOB clob) {
String content = null;
 StringBuffer stringBuf = new StringBuffer();
 try {
  int length = 0;
  Reader inStream = clob.getCharacterStream(); // 取得大字侧段对象数据输出流
  char[] buffer = new char[10];
  while ((length = inStream.read(buffer)) != -1) // 读取数据库 //每10个10个读取
  {
   for (int i = 0; i < length; i++) {
    stringBuf.append(buffer[i]);
   }
  }
 
  inStream.close();
  content = stringBuf.toString();
 } catch (Exception ex) {
 System.out.println("ClobUtil.Clob2String:" + ex.getMessage());
 }
 return content;
}




<resultMap id="noticeResult" type="java.util.Map">  
   <result property="NOTICE_ID" column="NOTICE_ID" javaType="int" jdbcType="INTEGER"/>  
   <result property="NOTICE_TITLE" column="NOTICE_TITLE" javaType="string" jdbcType="VARCHAR"/>  
   <result property="NOTICE_TYPE"  column="NOTICE_TYPE" javaType="int" jdbcType="INTEGER" />
   <result property="NOTICE_CONTENT"  column="NOTICE_CONTENT" jdbcType="CLOB" javaType = "java.lang.String" />
   <result property="NOTICE_URL_NAME"  column="NOTICE_URL_NAME" javaType="string" jdbcType="VARCHAR"/>
   <result property="NOTICE_SHOW_NAME"  column="NOTICE_SHOW_NAME" javaType="string" jdbcType="VARCHAR"/>
   <result property="NOTICE_STATUS"  column="NOTICE_STATUS" javaType="int" jdbcType="INTEGER" />
   <result property="CREATE_USER_ID"  column="CREATE_USER_ID" javaType="int" jdbcType="INTEGER"/>
   <result property="CREATE_TIME"  column="CREATE_TIME" javaType="java.sql.Timestamp" jdbcType="DATE"/>
   <result property="ADMIN_PRC"  column="ADMIN_PRC" javaType="string" jdbcType="VARCHAR"/>
    </resultMap>  
  
  <parameterMap id="noticePara" type="com.hp.pfm.salt.domain.Notice">  
   <parameter property="noticeId" jdbcType="INTEGER" javaType ="java.lang.Integer"/>  
   <parameter property="noticeTitle" jdbcType="VARCHAR" javaType ="java.lang.String"/>
   <parameter property="noticeType" jdbcType="INTEGER" javaType ="java.lang.Integer"/>  
   <parameter property="noticeContent" jdbcType="CLOB" javaType ="java.lang.String"/>
   <parameter property="noticeUrlName" jdbcType="VARCHAR" javaType ="java.lang.String"/>
   <parameter property="noticeShowName" jdbcType="VARCHAR" javaType ="java.lang.String"/>
   <parameter property="noticeStatus" jdbcType="INTEGER" javaType ="java.lang.Integer"/>  
   <parameter property="createUserId" jdbcType="INTEGER" javaType ="java.lang.Integer"/>
   <parameter property="createTime" jdbcType="DATE" javaType ="java.sql.Date"/>    
  </parameterMap>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值