Oracle clob處理____Oracle

來源:互聯網
上載者:User
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>


轉載自:http://blog.csdn.net/kiss_vicente/article/details/9214051

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.