String、Clob类型互相转换(oracle数据库)

1.StringToClob

Clob clob = new SerialClob(string.toCharArray());
Clob clob = Hibernate.createClob(string);

2.ClobToString

// 我看clob应该直接由toString()/setString()方法
// 我用的是流
public String ClobToString(Clob clob){
	String str = "";
	Reader reader = clob.getCharacterStream();
	// 得到流
	BufferedReader br = new BufferedReader(reader);
	String string = br.readLine();
	StringBuffer sb = new StringBuffer();
	while(string!=null){
		sb.append(string);
		string = br.readLine();
	}
	str = sb.toString();
	return str;
}

你可能感兴趣的:(oracle,oracle,big,data,hibernate,string)