Pass java objects to stored procedure in oracle

2

I'm having a problem trying to pass an object or fix from java to a store in my database. What happens is that when I try to pass an attribute that is string, this is being allocated empty in the STRUCT object the code is as follows

StructDescriptor itemDescriptor = StructDescriptor.createDescriptor("USUARIO.TY_REG_CORRESP",oracleConn);

         STRUCT[] idsArray = new STRUCT[registros.size()];
         int index=0;
         Map< String, Object> map = null;
        for (DatosArchivoTO registro:registros){
            map=new HashMap<String, Object>();
            map.put("VALOR", registro.getLinea());
            map.put("NUMERO_LINEA", registro.getNumLinea());
            /*Object[] itemAtributes = new Object[2];
            itemAtributes[0]=new String(registro.getLinea());
            itemAtributes[1]=registro.getNumLinea();*/

            STRUCT itemObject = new STRUCT(itemDescriptor,oracleConn,map);
            idsArray[index]=itemObject;
            index++;
        }

        ArrayDescriptor desc = ArrayDescriptor.createDescriptor("USUARIO.TY_LISTA_REG_CORRESP",oracleConn);
        ARRAY oracleArray = new ARRAY(desc,oracleConn ,idsArray);

When doing the debug I find that the first value in the itemObject object is not being assigned correctly

datumArray [???, oracle.sql.NUMBER@4ff353fd]

The objects in the database are the following:

CREATE OR REPLACE TYPE TY_REG_CORRESP AS OBJECT (VALOR VARCHAR2(200),
                                         NUMERO_LINEA NUMBER(9))

and

CREATE OR REPLACE TYPE TY_LISTA_REG_CORRESP AS TABLE OF USUARIO.TY_REG_CORRESP

Finally, I have a stored procedure that receives the array of objects and when trying to insert the data in the table, just insert the integer value and the string value as null.

I hope you can help me

    
asked by Fisckoer8 14.06.2016 в 21:36
source

1 answer

1

Well, after almost a whole day I found the solution to the problem and it is as follows:

Apparently this is an encoding problem between the database and the client, for which the solution I found is that you have to add the lib orai18n.jar to the project, this solves the problem.

    
answered by 15.06.2016 в 20:56