R
relogout
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.iutputStream out = clob.setAsciiStream(0);
(3) Writer outStream = clob.getCharacterOutputStream();
4. update the table
sql3="update TAB1 set COL_CLOB=? where id='1'";
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.iutputStream out = clob.setAsciiStream(0);
(3) Writer outStream = clob.getCharacterOutputStream();
4. update the table
sql3="update TAB1 set COL_CLOB=? where id='1'";