How to slove this Clob problem
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??