oracle Array filled with null data in java

六月ゝ 毕业季﹏ 提交于 2019-12-05 02:07:46

问题


When I try to throw an Array of strings to oracle stored procedure as:

String arrStr[] ={"val1","val2","val3"};
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("STR_ARRAY", connection );

oracle.sql.ARRAY oracleArray = new oracle.sql.ARRAY(descriptor, connection, arrStr);

oracleArray holds null data , oracleArray.datumArray = {???,???,???}


回答1:


In my case (see my comment above), it was caused by encoding problem, however - without any exception or debug information. Including orai18n.jar to the project libraries solved this... it is really sad, there is no exception or something that would indicate how to solve the problem




回答2:


After hours I have founded the cause, the real problem is the NLS_CHARACTERSET of your database work with a encoding that is not supported by your client, to jdbc support others NLS_LANG is necessary add orai18n.jar in classpath. See your database settings with this sql:

SELECT * FROM NLS_DATABASE_PARAMETERS




回答3:


Probably your STR_ARRAY is defined in this way:

create or replace type STR_ARRAY is table of VARCHAR2(20);

As Tomas said the problem is encoding. My solution - use NVARCHAR2 instead.

create or replace type STR_ARRAY is table of NVARCHAR2(20);



来源:https://stackoverflow.com/questions/14998299/oracle-array-filled-with-null-data-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!