some problem with CLOB

vitamines 2008-09-10 11:01:45
I have a oracle table with a CLOB field named NEWS_CONTETN, and I want put some news information which may be larger than 4k, I have searched for some example and take following steps:

1. insert an empty clob to the table
sql1="insert into TAB1(id,COL_CLOB) values(1,empty_clob())";

2. initialize a CLOB variable and select the clob field for update

sql2="select COL_CLOB from TAB1 where id=1 for update";
oracle.sql.CLOB clob=null;
if(rs.next()){
clob=(oracle.sql.CLOB)rs.getClob("COL_CLOB");
}


3. put the news information to the CLOB variable
===================
HERE IS MY PROBLEM
in step 3, i have tried 3 ways, but it didn't work :(
===================
(1) clob.putChars(1,newsStr.toString().toCharArray()); //newsStr is a string
(2) java.io.OutputStream out = clob.setAsciiStream(0);
(3) Writer outStream = clob.getCharacterOutputStream();

4. update the table
sql3="update TAB1 set COL_CLOB=? where id='1'";



---------------------------------
I can't use any method of oracle.sql.CLOB, and get an exception null
what should i do? pls anyone help me, thanks in advance!
...全文
98 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinsu_st 2008-09-10
  • 打赏
  • 举报
回复
Where are you from? I can't follow you!
vitamines 2008-09-10
  • 打赏
  • 举报
回复
oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("content");

我是只能进行到赋值的操作,之后对clob变量进行任何方法的调用都会抛出exception
ee4456 2008-09-10
  • 打赏
  • 举报
回复
http://www.javaeye.com/topic/38573
ee4456 2008-09-10
  • 打赏
  • 举报
回复
spring jdbc

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧