I am trying to insert a large XML doc into an XMLType column in Oracle 9i using jdbc. I am having a problem because the size of the doc is over 4k. I have not been sucessful in inserting. However, I feel a good strategy is to treat the xmltype insert as a CLOB insert. I'm not sure if it will work???? Any suggestions would be greatly appreciated!
here is the code I have working with. The table is called xmltest and has 2 columns id number and peaklist xmltype.
try
{
con.setAutoCommit(false);
String sql1="insert into XMLTest (id,peaklist) VALUES(?,sys.xmlType.createXML(empty_Clob()))";
PreparedStatementps=con.prepareStatement(sql1);
ps.setInt(1,1);
ps = con.prepareStatement("SELECT * from xmltest where id = 1 FOR UPDATE");
rs=ps.executeQuery();
if(rs.next())
{
oracle.sql.CLOB myCLOB = (oracle.sql.CLOB)rs.getObject("peaklist");
java.io.Writer CLOBout = myCLOB.getCharacterOutputStream();
String XMLDoc = SparkyToXml.SparkyToXml(peakListLoc);
out.println("XMLDOC " + XMLDoc);
CLOBout.write(XMLDoc);
}
rs.close();
ps.close();
con.commit();
con.setAutoCommit(true);
}catch(Exception e) { out.println("error in 1 " + e);}
I am recieving a nullpointer exeception. Help!!!