Clob类型
CLOB全称为字符大型对象(Character Large Object)。它与LONG数据类型类似,只不过CLOB用于存储数据库中的大型单字节字符数据块,不支持宽度不等的字符集。可存储的最大大小为4G字节。使用时不需要设置长度,直接使用,用于存储字符型数据。
Clob转String
varchar2的最大存储长度是4000。
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) {
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
return reString;
}
Clob clob = rs.getClob("PARA")
String para = clob.getSubString(1, (int)clob.length())