java读取Oracle Java读取Oracle大字段数据(CLOB)的2种方法
Steven5007 人气:0Oracle数据库中有一个字段是CLOB类型,使用java 解析.
1.使用java解析clob类型内容
public String clobToString(Clob c) { StringBuffer sb = new StringBuffer(1024); Reader instream = null; try { instream = c.getCharacterStream(); char[] buffer = new char[(int) c.length()]; int length = 0; while ((length = instream.read(buffer)) != -1) { sb.append(buffer, 0, length); } } catch (Exception ex) { ex.printStackTrace(); return null; } finally { try { if (instream != null) instream.close(); } catch (Exception dx) { instream = null; } } return sb.toString(); }
if(pageObject.getResultList() != null && pageObject.getResultList().size() > 0){ for(int i=0,j=pageObject.getResultList().size(); i < j;i++){ Map<String,Object> maps = (Map<String, Object>) pageObject.getResultList().get(i); maps.put("DISPATCHINGRULESNAME",this.clobToString((Clob) maps.get("DISPATCHINGRULESNAME"))); //这里将Clob类型转化成字符串,调用clobToString((Clob)方法 } }
2.使用oracle函数 to_char(字段)
select to_char(t.billName) as billName from T_CC_SHARE_DISPATCH_RULE t
加载全部内容