你们能告诉我如何使用 jdbc 插入 clob 数据吗?我正在使用oracle10g数据库。
我能够使用以下两种方法插入长度 < 4000 的 clob 数据
1.
tempClob.length()<4000){
pstmnt.setClob(colNumber, tempClob );
}
2.
tempClob.length()<4000){
Reader reader =tempClob.getCharacterStream();
pstmnt.setClob(colNumber, tempClob );
pstmnt.setCharacterStream(colNumber, reader, new Long(tempClob.length()).intValue());
}
当 clob 数据的长度很大时,例如 abt 29k,这两种方法都会失败。
最佳答案
这适用于 oracle11g jdk5
tempClob.length()<4000){
byte[] bytes = tempClob.getBytes();
pstmnt.setCharacterStream(2, new StringReader(new String( bytes )), bytes.length);
}
关于java - 如何使用 jdbc 在 oracle 10g 中插入大型 clob 数据(> 4K 字符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6684214/