Java - como guardar un texto en formato RTF en un campo CLOB o BLOB (Oracle) con Java

 
Vista:

como guardar un texto en formato RTF en un campo CLOB o BLOB (Oracle) con Java

Publicado por alfonso (6 intervenciones) el 28/10/2015 12:34:44
Buenos dias,

Estoy intentando guardar el siguiente contenido en formato RTF en un campo CLOB o BLOB (oracle) con Java:

\E\rtf1\E\adeflang1025\E\ansi\E\ansicpg1252\E\uc1\E\adeff0\E\deff0\E\stshfdbch0\E\stshfloch37\E\stshfhich37\E\stshfbi37\E\deflang1046\E\deflangfe1046\E\
themelang1046\E\themelangfe0\E\themelangcs0{\E\fonttbl{\E\f0\E\fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\E\panose 02020603050405020304}Times New Roman;}{\E\f0\E\
fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\E\panose 02020603050405020304}Times New Roman;}\.br\{\E\f37\E\fbidi \E\fswiss\E\fcharset0\E\fprq2{\E\*\E\panose
020f0502020204030204}Calibri;}{\E\flomajor\E\f31500\E\fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\E\panose 02020603050405020304}Times New Roman;}\.br\{\E\fdbmajor\E\
f31501\E\fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\E\panose 02020603050405020304}Times New Roman;}{\E\fhimajor\E\f31502\E\fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\
E\panose 02040503050406030204}Cambria;}\.br\{\E\fbimajor\E\f31503\E\fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\E\panose 02020603050405020304}Times New Roman;}
{\E\flominor\E\f31504\E\fbidi \E\froman\E\fcharset0\E\fprq2{\E\*\E\panose 02020603050405020304}Times New Roman;}.... <continua en el arquivo txt adjunto>

Realize una función para convertir de String para Clob pero no esta funcionando correctamente:
public static CLOB getCLOB( String clobData ){
CLOB tempClob = null;
try {
tempClob = new CLOB((oracle.jdbc.OracleConnection)dbConnection,clobData.getBytes());
} catch (Exception exp) {
System.out.println("erro"+exp);
}
return tempClob;
}

y luego realizo el insert en la tabla:

public void insert(String Id, String patientId, String instituteId, String orderAccessionNumber, String staffMemberVerified, String staffMemberDictated, String reportApprovalDate, String medicalReport, String controlDate ) {

String insert = "insert into " + tableName + " (ID, PID_ID, UNIDADE_ID, OBR_ACCESSION_NUMBER, OBR_PRINCIPAL_RESULT_INTERP, OBR_ASSISTANT_RESULT_INTERP, OBR_RESULT_DATE, CTRL_DATE, CTRL_STATUS, DATA_INTEGRACAO, DS_ERRO_INTEGRACAO, TST_OBX_OBSERVATION_VALUE,OBX_OBSERVATION_VALUE) values (DBASIH.seq_report_data.Nextval,'"+patientId+"', '"+instituteId+"', '"+orderAccessionNumber+"', '"+staffMemberVerified+"', '"+staffMemberDictated+"', sysdate, sysdate, 'N','','','','"+getCLOB(medicalReport)+"') ";
SimpleLog.print("Insert report:");
SimpleLog.print("orderIdPK:" +patientId);
SimpleLog.print("orderId:" +orderAccessionNumber);
SimpleLog.print("insert: " + insert);



Existe otra forma de realizar esto, algun ejemplo que me pueda ayuda???
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Lawliet
Val: 308
Ha mantenido su posición en Java (en relación al último mes)
Gráfica de Java

como guardar un texto en formato RTF en un campo CLOB o BLOB (Oracle) con Java

Publicado por Lawliet (303 intervenciones) el 28/10/2015 17:38:32
Hola...

Por que no intentas cambiar tu campo BLOB a CLOB, de esta manera podrás insertar los valores como si fuera un String, sino me equivoco, un campo BLOB viene siendo un tipo de campo que te permite trabajar con archivos multimedia ya que el campo te permite guardar información binaria en grandes cantidades, caso contrario a un campo CLOB ya que este únicamente permite guardar grandes cantidades de caracteres; es decir, cadenas.

Intenta hacer la prueba y ya nos comentas el resultado. Sin más que comentar, cualquier duda y/o inconveniente aquí estamos.

Suerte!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar