简体   繁体   English

在Java中将ArrayList传递给Oracle存储过程

[英]Passing ArrayList to Oracle Stored Procedure in Java

Is there a way to pass a Java ArrayList object as a parameter to an Oracle Stored Procedure? 有没有办法将Java ArrayList对象作为参数传递给Oracle存储过程? I have seen examples of passing an Array object to an Oracle Stored Procedure, but not an ArrayList object. 我已经看到了将Array对象传递给Oracle存储过程但不是ArrayList对象的示例。 Is this possible? 这可能吗?

No. If the Oracle stored procedure is in PL/SQL you must convert your ArrayList (or any List implementation) into an array. 否。如果Oracle存储过程在PL / SQL中,则必须将ArrayList(或任何List实现)转换为数组。

If your stored procedure is written in Java, you could serialize your ArrayList, send the byte stream to Oracle as a long string, and reconstitute it on the Oracle side. 如果存储过程是用Java编写的,则可以序列化ArrayList,将字节流作为长字符串发送给Oracle,然后在Oracle端重新构建它。 I did this about 10 years ago for a client and it worked very well. 大约10年前,我为一位客户做了这件事,而且效果非常好。 There are limits on how long a string you can pass across the Java-Oracle interface so if your data structure is large you will have to divide it into chunks that will fit into a single parameter, and have the Java on the Oracle side accept multiple long string parameters. 您可以通过Java-Oracle接口传递字符串的时间有限,因此如果您的数据结构很大,则必须将其划分为适合单个参数的块,并让Oracle端的Java接受多个长字符串参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM