您的位置:首页 > 其它

JARF框架CLOB类型转为String类型字段

2018-01-15 09:49 375 查看
用list去接收数据,然后再将对应的CLOB字段转为String类型,随之显示在jsp页面

List<HashMap<String, Object>> objList= (List<HashMap<String, Object>>) commonDao.queryByNamedSqlForList(GDFAMC + "queryMeetResolution",
meet_vote_detial_id);

if (objList!=null&&objList.size()>0) {
map=objList.get(0);
if(map.get("council_summary_report")!=null&&"oracle.sql.CLOB".equals(map.get("council_summary_report").getClass().getName())){
Clob council_summary_report=(Clob) map.get("council_summary_report");
String council_summary_reportStr=ClobToString(council_summary_report);
map.put("council_summary_report", council_summary_reportStr);
objList.clear();
objList.add(map);
}
}
// Element e2 = commonDao.queryByNamedSql(GDFAMC + "queryDesAsset",meet_vote_detial_id);
req.addRspData(XmlUtil.createDataObjectElement(objList).removeContent());

正常的java框架转换方法:

// 将字CLOB转成STRING类型   

    public String ClobToString(Clob clob) throws SQLException, IOException {   

          

        String reString = "";   

        java.io.Reader is = clob.getCharacterStream();// 得到流   

        BufferedReader br = new BufferedReader(is);   

        String s = br.readLine();   

        StringBuffer sb = new StringBuffer();   

        while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING   

            sb.append(s);   

            s = br.readLine();   

        }   

        reString = sb.toString();   

        return reString;   

    }  

页面转化为CLOB:

String content = ClobToString((Clob)obj[1]);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: