java - Spring parameter to store procedure ArrayDescriptor with attribute blob -


i'm using spring 3.2.2 , java code:

@override public void writesql(sqloutput stream) throws sqlexception {      stream.writeint(this.intidndcarchivoadjunto);     stream.writeint(this.objnotacredito.getintid());     stream.writestring(this.strnombrearchivo);     stream.writestring(this.strformatoarchivo);     stream.writeint(this.objtipoarchivo.getintidtipoarchivo());      oracle.sql.blob blob = oracle.sql.blob.getemptyblob();     blob.setbytes(getobjarchivocargado());      stream.writeblob(blob); } 

i have in oracle:

create or replace type "tp_obj_ndc_archivo"  object( id_ndc_archivo_adjunto number, id_ndc number, nombre_archivo varchar2(50), formato varchar2(5), tipo_archivo number, archivo blob );  create or replace type "tp_arr_ndc_archivo" table of tp_obj_ndc_archivo; 

i did several examples arraydescriptor have problems when contains type blob:

org.springframework.jdbc.uncategorizedsqlexception: callablestatementcallback; uncategorized sqlexception sql [{call cadco.pck_notas_credito.crearsolicitudndc(?, ?, ?, ?, ?, ?, ?, ?, ?)}]; sql state [60000]; error code [600]; ora-00600: código de error interno, argumentos: [kollasg:client lob on server], [], [], [], [], [], [], [], [], [], [], [] ; nested exception java.sql.sqlexception: ora-00600: código de error interno, argumentos: [kollasg:client lob on server], [], [], [], [], [], [], [], [], [], [], []

esto funciono, falta depurar el código. lo dejare aquí para quien le sirva.

public void insertall(notacreditoarchivoadjunto [] arrnotacreditoarchivoadjunto) {      connection conn=null;     structdescriptor structdescriptor=null;     arraydescriptor arraydescriptor=null;     int isize = arrnotacreditoarchivoadjunto.length;     object[] arrobj =null;     object[][] recobj =null;     try {      this.jdbctemplate = new jdbctemplate(datasource);      conn=jdbctemplate.getdatasource().getconnection(); 

// oracleconnection oraconn = conn.unwrap(oracleconnection.class);

    structdescriptor = structdescriptor.createdescriptor(oracle_struct, oraconn.getmetadata().getconnection());     arraydescriptor = arraydescriptor.createdescriptor(oracle_array, oraconn.getmetadata().getconnection());      arrobj = new object[isize];     recobj = new object[isize][6];      //structuring obj , arrays     (int j = 0; j < isize ;j++){      notacreditoarchivoadjunto ob = arrnotacreditoarchivoadjunto[j];     recobj[j][0]=ob.getintidndcarchivoadjunto();     recobj[j][1]=ob.getobjnotacredito().getintid();     recobj[j][2]=ob.getstrnombrearchivo();     recobj[j][3]=ob.getstrformatoarchivo();     recobj[j][4]=ob.getobjtipoarchivo().getintidtipoarchivo();      blob blob = blob.createtemporary(oraconn,false,blob.duration_session);     outputstream outputstream = blob.setbinarystream(0l);     inputstream inputstream = new bytearrayinputstream(ob.getobjarchivocargado());     byte[] buffer = new byte[blob.getbuffersize()];     int bytesread = 0;     while((bytesread = inputstream.read(buffer)) != -1){         outputstream.write(buffer,0,bytesread);     }     outputstream.close();     inputstream.close();      recobj[j][5]= blob;      arrobj[j] = new struct(structdescriptor, oraconn.getmetadata().getconnection(), recobj[j]);      }     array arr = new array(arraydescriptor, oraconn.getmetadata().getconnection(), recobj);      preparedstatement preparedstatement=conn.preparestatement("{call cadco.pck_notas_credito.borrar (?)}");     preparedstatement.setarray(1, arr);     preparedstatement.execute();      }catch (exception e) {          e.printstacktrace();     } finally{     try {     if (conn != null){         conn.close();         }     }          catch (sqlexception e2) {             e2.printstacktrace();         }     } } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -