无法将数组作为输入参数将来自Java的OracleCallableStatement设置
Oracle代码:
PROCEDURE get_details (
p_array IN XXX_TYPES,
.....
......
)
其中XXX_TYPE是Oracle中的复杂类型:
TYPE IDType
IS
RECORD
(
c_number c_table.c_number%TYPE
);
TYPE XXX_TYPES
IS
TABLE OF IDType;
以及用于设置输入参数的Java代码:
//Create an array of Struct objects
Object[] array = new Object[] {"1", "2"};
OracleStruct createStruct1 = (OracleStruct) con.createStruct("IDType", array);
Struct[] structArray = new Struct[] {createStruct1};
OracleArray createOracleArray = (OracleArray)con.createOracleArray("XXX_TYPES",structArray);
//Set the input parameter
cs.setArray(1, createOracleArray);
获得Oraclestruct createstruct1 =(oraclestruct)con.CreatStruct(“ idtype”,“ idtype”,array)的例外;线: 意外错误-java.sql.sqlexception:不一致的Java和SQL对象类型,对于实现Oradata或oracledata的类,应在TypeMap中注册各个工厂Oradatafactory和Oracledatafactory。
看上去是sof,但大多数都提到现在已弃用。 请感谢在此或任何指向设置和数组的链接中的任何帮助,因为存储过程输入参数可以做到。
The oracle code :
PROCEDURE get_details (
p_array IN XXX_TYPES,
.....
......
)
where XXX_TYPES is a complex type in Oracle:
TYPE IDType
IS
RECORD
(
c_number c_table.c_number%TYPE
);
TYPE XXX_TYPES
IS
TABLE OF IDType;
And the java code to set input Parameter :
//Create an array of Struct objects
Object[] array = new Object[] {"1", "2"};
OracleStruct createStruct1 = (OracleStruct) con.createStruct("IDType", array);
Struct[] structArray = new Struct[] {createStruct1};
OracleArray createOracleArray = (OracleArray)con.createOracleArray("XXX_TYPES",structArray);
//Set the input parameter
cs.setArray(1, createOracleArray);
Getting exception for OracleStruct createStruct1 = (OracleStruct) con.createStruct("IDType", array); line:
unexpected error - java.sql.SQLException: Inconsistent java and sql object types, for classes implementing ORAData or OracleData, respective factory classes ORADataFactory and OracleDataFactory should be registered in typeMap.
Looked SOF but most of them referred to StructDescriptor which is deprecated now.
appreciate any help on this or any link to setting and array as stored procedure input parameter would do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论