Oracle中Clob类型的字段数据转换成String字符串

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/abc_email/article/details/50594669

具体函数如下:

//clob 转换 String (传入 clob 类型的 obj 对象)
public static String getClob2String(Object obj) {
	String str = "";
	try {
		CLOB clob = (CLOB) obj;
		if (clob == null || clob.length() == 0) {
			str = "";
		} else {
			long clen = clob.length();
			char clobArray[] = new char[(int) clen];
			int readednum = clob.getChars(1, (int) clen, clobArray);
			StringBuffer sb = new StringBuffer();
			sb.append(clobArray);
			str = sb.toString();
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return str;
}


展开阅读全文

没有更多推荐了,返回首页