RE:Ayuda - Convertir String a Clob
Publicado por
Pablo (1 intervención) el 06/10/2006 17:31:25
Uno de los metodos mas utilizados y mas comunque podrás encontrar es este.
Saludos
Pablo
private CLOB getCLOB(String xmlData, Connection conn) throws SQLException{
CLOB tempClob = null;
try{
// If the temporary CLOB has not yet been created, create new
tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
// Open the temporary CLOB in readwrite mode to enable writing
tempClob.open(CLOB.MODE_READWRITE);
// Get the output stream to write
Writer tempClobWriter = tempClob.getCharacterOutputStream();
// Write the data into the temporary CLOB
tempClobWriter.write(xmlData);
// Flush and close the stream
tempClobWriter.flush();
tempClobWriter.close();
// Close the temporary CLOB
tempClob.close();
} catch(SQLException sqlexp){
tempClob.freeTemporary();
sqlexp.printStackTrace();
if(conn!=null )conn.close();
} catch(Exception exp){
tempClob.freeTemporary();
exp.printStackTrace();
if(conn!=null )conn.close();
}
return tempClob;
}