I have a stored procedure in Oracle like below.
create or replace TYPE T_EMP_OBJ AS OBJECT (Name varchar2(20), Age CHAR(3 CHAR));
create or replace type T_EMP_REC as table of T_EMP_OBJ;
create or replace PROCEDURE P_EMP (I_NAV_REC IN T_INAV_REC, p_out OUT MY_TYPES_PKG.REFCURSOR)
AS ...
END P_EMP;
I am calling that procedure from java. My code is,
StructDescriptor structDesc = new StructDescriptor("T_EMP_OBJ", oracleConnection);
ArrayDescriptor arrayDesc2 = new ArrayDescriptor("T_EMP_REC", oracleConnection);
Object[] objType = new Object[2];
objType[0] = new String("AAA");
objType[1] = new String("25");
STRUCT struct = new STRUCT(structDesc, oracleConnection, objType);
STRUCT[] structs = new STRUCT[1];
structs[0] = struct;
oracle.sql.ARRAY array = new oracle.sql.ARRAY(arrayDesc2, oracleConnection, structs);
OracleCallableStatement statement = (OracleCallableStatement) oracleConnection.prepareCall("CALL P_EMP(?,?)");
statement.setArray(1, array);
statement.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);
statement.execute();
ResultSet results = ((OracleCallableStatement) statement).getCursor(2);
while (results.next()) {
logger.info("NAME==>"+results.getString(1));
logger.info("AGE===>"+results.getString(2));
}
Eventhough I am getting records, the value is null. That means if the output is 2 rows, then the while condition executing and printing null. In SQL Developer it is working fine. Thanks in advance.
解决方案
Finally found the answer here. After including the orai18n.jar in class path, it is working fine.