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]);
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]);
相关文章推荐
- 原生sql 查clob字段,查出的结果是string类型
- java将Oracle中的clob转为String类型
- Oracle数据库中CLOB类型字段取出转换String类型方法
- java Clob类型的字段转化为String类型的字段
- 【转】将ORACLE数据库表中字段的varchar类型转为CLOB?
- Oracle中Clob类型的字段数据转换成String字符串
- spring MVC框架下Controller接收Session并转为String类型
- Oracle的Clob字段设置为String类型
- Oracle 中Clob 字段,转换为 String 类型
- JAVA中将String类型转为Date写入数据库的datatime类型字段中
- iBatis操作CLOB类型字段时报setString can only process strings of less than 32766 chararacters
- SSH对Clob字段类型的支持
- Oracle中如何查询CLOB字段类型的内容
- Oracle中如何查询CLOB字段类型的内容
- TP框架数据表字段类型缓存清除方法
- 文件的导入导出(CLOB类型字段)_Oracle_java
- string格式的日期时间字符串转为DateTime类型
- clob转化String类型
- hibernate在SSH框架操作ORACLE Clob字段类型的读写改
- spring mvc String类型转为一个对象