1.在resultmap中加入
<result property="content" column="PRN_TPL_CONTENT" typeHandler="org.springframework.orm.ibatis.support.ClobStringTypeHandler" />
2.使用方法转换
<result property="content" column="PRN_TPL_CONTENT" typeHandler="org.springframework.orm.ibatis.support.ClobStringTypeHandler" />
2.使用方法转换
public String ClobToString(CLOB clob) throws SQLException, IOException {
String reString = "";
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;
}
本文介绍了一种在MyBatis中处理大型文本数据CLOB的方法。通过在ResultMap中配置特定类型处理器,并提供了一个实用的方法将CLOB转换为String。这对于处理数据库中的大量文本数据非常有用。
905

被折叠的 条评论
为什么被折叠?



