El procedimiento pl/sql devuelve 3 signos de interrogación ('???') para columnas varchar2 (wls 10.3.4 - weblogic 11g)

I got the following code that works fine on OAS10, for fetching array of custom object from sql procedure:

Connection conn = null;
OracleCallableStatement stmt = null;
RequestsWrapper requestsWrapper = null;
conn = getConnection(DATASOURCE);
if (conn != null) {
    stmt = (OracleCallableStatement) conn.prepareCall("{call packageName.procedureName(?, ?, ?)}");
    stmt.registerOutParameter(3, OracleTypes.ARRAY, "V_ARRAY_OF_CUSTOM_OBJECTS");
    stmt.setString(1, in1);
    stmt.setString(2, in2);
    stmt.execute();
    ARRAY zahtjev = (ARRAY) cs.getArray(3);
    RequestsWrapper requestsWrapper = new RequestsWrapper();
    for (Object object : (Object[]) zahtjev.getArray()) {
        if (object != null) {
              CustomObject co = new CustomObject();
              Object[] attributes = ((STRUCT) object).getAttributes();
              co.setVarcharAttribute((String) attributes[0]);
              co.setNumericAttribute(((BigDecimal) attributes[1]).intValue());
              requestsWrapper.getObjectList().add(co);
       }
    }
}

and I have to migrate application to WLS 10.3.4. When I tried to execute existing code, I got an exception: cannot cast to oracle.sql.ARRAY. I found in WLS documentation:

For most extensions in the Oracle Thin driver, you can use the standard technique as described in Using API Extensions to JDBC Interfaces. However, the Oracle Thin driver does not provide public interfaces for its extension methods in the following classes:

oracle.sql.ARRAY
oracle.sql.STRUCT
oracle.sql.REF
oracle.sql.BLOB oracle.sql.CLOB

WebLogic Server provides its own interfaces to access the extension methods for those classes:

weblogic.jdbc.vendor.oracle.OracleArray weblogic.jdbc.vendor.oracle.OracleStruct weblogic.jdbc.vendor.oracle.OracleRef weblogic.jdbc.vendor.oracle.OracleThinBlob weblogic.jdbc.vendor.oracle.OracleThinClob

So, I followed the instructions and I got following code

Connection conn = null;
OracleCallableStatement stmt = null;
RequestsWrapper requestsWrapper = null;
conn = getConnection(DATASOURCE);
if (conn != null) {
    ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor("V_ARRAY_OF_CUSTOM_OBJECTS", conn);
    StructDescriptor structDescriptor = StructDescriptor.createDescriptor("T_CUSTOM_OBJECT", conn);
    stmt = (OracleCallableStatement) conn.prepareCall("{call packageName.procedureName(?, ?, ?)}");
    stmt.registerOutParameter(3, OracleTypes.ARRAY, "V_ARRAY_OF_CUSTOM_OBJECTS");
    stmt.setString(1, in1);
    stmt.setString(2, in2);
    stmt.execute();
    Array request = stmt.getArray(3);
    OracleArray requestOracleArray =  ((weblogic.jdbc.vendor.oracle.OracleArray)request).getOracleArray(); 
    Datum[] datumArray = ((weblogic.jdbc.vendor.oracle.OracleArray)request).getOracleArray();
    RequestsWrapper requestsWrapper = new RequestsWrapper();
    for (Datum object : datumArray) {
        if (object != null) {
           CustomObject co = new CustomObject();
           Object[] attributes = ((Struct) object).getAttributes();
           co.setVarcharAttribute((String) attributes[0]);
           co.setNumericAttribute(((BigDecimal) attributes[1]).intValue());
           requestsWrapper.getObjectList().add(co);
       }
    }
}

and numeric attribute is mapped OK, but instead of varchar2 attribute, I have '???'. Does anyone have similar problem?

Gracias de antemano.

edit: i found on few pages info that orai18n.jar should be added to server classpath. but it doesn't work for me.

preguntado el 05 de septiembre de 12 a las 10:09

2 Respuestas

at the end, orai18n.jar is solution. i had to include it in CLASSPATH of weblogic, so in %MY_DOMAIN%\bin folder in setDomainEnv.cmd just added

set CLASSPATH=%WL_HOME%\server\ext\jdbc\oracle\11g\orai18n.jar

and now it works :)

Respondido el 05 de Septiembre de 12 a las 15:09

Sometimes it means you have unicode stuff in your varchar2 fields. Please consider about it.

Respondido el 05 de Septiembre de 12 a las 15:09

that was first hint, that i had special characters. so, i checked fields and now varchar2 fileds are 'clean'. only characters a-z and 0-9 are inside. - Kenny

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.