Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to slove this Clob problem

265044Jul 1 2002
Hi all,
First I defined a table in oracle8i using the following code:
create xmltab(id number primary key,xml_content clob);
then in jdev9i ,I wrote the following code:
try{
...
Connection con=getConnection();
PreparedStatement pstmt =
con.prepareStatement ("insert into xmltab (id, xml_content) values (id_seq.NEXTVAL, ?)");

//a very large String is stored in tempBuffer

pstmt.setCharacterStream(1,new StringReader(tempBuffer.toString()),tempBuffer.toString().length());
pstmt.execute();
con.commit();
pstmt.close();
con.close();
tempBuffer.delete(0,tempBuffer.toString().length());
JOptionPane.showInternalMessageDialog(this.getContentPane(),"l,w",""
,JOptionPane.INFORMATION_MESSAGE);
}catch(Exception e1){
e1.printStackTrace();
}

I found that the String in StringBuffer is truncated when it is commited to database.But if change the xmltab definition as:
xmltab(id number primary key,xml_content varchar2(4000));
the result is right,but i hope that the String length is larger than 4000 when is insert into xmltab,How can i solve this problem?

How can i use setClob(index,Clob) when meeting the String type??


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 29 2002
Added on Jul 1 2002
1 comment
190 views