Xml to clob

Pessoal,

Preciso gravar um arquivo XML dentro deum campo clob no oracle, alguem sabe como posso fazer isso ?. O arquivo xml eu to conseguindo gerar (crio um arquivo org.w3c.dom.Document), mas não to encontrando documentação sobre como guardar isso em um campo clob.

Como vc solucionou o seu problema? Preciso disso tb.

Não solucionei, fui demitido e não quero mais falar sobre isso.

To brincando:

String str= “valor a gravar no clob”;
Reader r = new StringReader(str);
pstmt.setCharacterStream(9, r, clobContent.length());

onde pstmt é o preparedStatement.

Encontrei outras formas na net, mas em todas encontrei alguns problemas pra gravar o xml que eu queria. No caso acima eu gerei o XML utilizando DOM e depois converti ele pra string(str) …

public static String getDocumentAsXml(Document doc) throws TransformerConfigurationException, TransformerException {

	  DOMSource domSource = new DOMSource(doc);
	  TransformerFactory tf = TransformerFactory.newInstance();
	  Transformer transformer = tf.newTransformer();
	  transformer.setOutputProperty(OutputKeys.METHOD, "xml");
	  transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
	  
	  transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
	  transformer.setOutputProperty(OutputKeys.INDENT, "yes");

	  java.io.StringWriter sw = new java.io.StringWriter();
	  StreamResult sr = new StreamResult(sw);
	  transformer.transform(domSource, sr);

	  return sw.toString();
}

vlw. Consegui usando JPA também com a anotação @Lob

Vlw mesmo.