高手救命啊,tomcat连接池连接oracle操作Clob产生java.lang.ClassCastException异常

04-10-18 openg
用jdbc连没问题,一用tomcat连接池,操作大字段就出现java.lang.ClassCastException: oracle.sql.CLOB错误

// 在此输入java代码
String sSql = "INSERT INTO TEST_CLOB VALUES (?, EMPTY_CLOB())";
ps = conn.prepareStatement(sSql);
ps.setString(1, test_id);
ps.executeUpdate();
ps.close();
ps = null;

String selectSql = "SELECT CLOBCOL FROM TEST_CLOB WHERE TEST_ID=? FOR UPDATE";
ps = conn.prepareStatement(selectSql);
ps.setString(1,test_id);
rs = ps.executeQuery();
Clob clob = null;
if (rs.next()) {
	//oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob("CLOBCOL");
	clob = (Clob) rs.getClob("CLOBCOL");

	Writer wr = ((oracle.sql.CLOB)clob).getCharacterOutputStream();
	wr.write("aaa");
	wr.flush();
	wr.close();
}
<p>

谢了先

猜你喜欢