I have a requirement where in I have to write XML contents to Clob. This is the piece of code I have written,
File xmlFile = new File("D:\\Test\\sampleXML.xml");
BufferedReader br = new BufferedReader(new FileReader(xmlFile));
while ((xmlLine = br.readLine()) != null) {
xmlString.append(xmlLine);
}
char[] xmlBuf = xmlString.toString().toCharArray();
Clob xmlClob1 = new SerialClob(xmlBuf);
System.out.println("Clob(xmlClob1) Size = "+xmlClob1.length());
PreparedStatement pStmt = conn.prepareCall("{call insertworkfile(?)}");
pStmt.setClob(1,(Clob)xmlClob1);
But I get an error at the "setClob()" method
The error is -
java.lang.ClassCastException: javax.sql.rowset.serial.SerialClob
Can you anyone help me out of this?
I did go through lot of forums where folks spoke about using select statement to get an empty clob first,then update the clob retrieved and send it as an input. But I am not allowed to do anything like this? Can you please let me know what I need to do to solve this?
Any help is highly appreciated.