---
title: "ibatis中 oracle的 clob 类型转换为string"
author: "roc08"
date: "2011-08-17T16:22:18Z"
tags: []
categories: ["数据库"]
slug: "ibatis-oracle-clob-string"
draft: false
lastmod: "2011-08-17T16:22:41Z"
id: 1151505
url: "https://roc08.iteye.com/blog/1151505"
---

1.在resultmap中加入
<result property="content" column="PRN_TPL_CONTENT" typeHandler="org.springframework.orm.ibatis.support.ClobStringTypeHandler" />

2.使用方法转换

```java

	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;
	}


```