I have to send an array to a stored procedure as a parameter from java program. how can we do that. please help me in this
我必须将一个数组作为参数从java程序发送到存储过程。我们怎么能这样做。请帮帮我
2 个解决方案
#1
1
This is a vendor centric implementation and so would be different for different databases. For Oracle you need to use ArrayDescriptor class of oracle.sql package. Follow the link below for a sutable answer discussed on AskTom site: http://asktom.oracle.com/pls/asktom/f?p=100:11:2906896739396193::::P11_QUESTION_ID:712625135727
这是以供应商为中心的实现,因此对于不同的数据库会有所不同。对于Oracle,您需要使用oracle.sql包的ArrayDescriptor类。请点击以下链接,在AskTom网站上讨论一个可靠的答案:http://asktom.oracle.com/pls/asktom/f?p = 100:11:2906896739396193::::P11_QUESTION_ID:712625135727
#2
1
That depends on your database. Some databases (for example Postgres, HSQLDB) and their JDBC drivers support anonymous arrays, which you can set with
这取决于您的数据库。某些数据库(例如Postgres,HSQLDB)及其JDBC驱动程序支持匿名数组,您可以使用它们进行设置
Object[] array = // ...
pstmt.setObject(index, array);
Oracle is more complex as it needs a typed object.
Oracle更复杂,因为它需要一个类型化的对象。
#1
1
This is a vendor centric implementation and so would be different for different databases. For Oracle you need to use ArrayDescriptor class of oracle.sql package. Follow the link below for a sutable answer discussed on AskTom site: http://asktom.oracle.com/pls/asktom/f?p=100:11:2906896739396193::::P11_QUESTION_ID:712625135727
这是以供应商为中心的实现,因此对于不同的数据库会有所不同。对于Oracle,您需要使用oracle.sql包的ArrayDescriptor类。请点击以下链接,在AskTom网站上讨论一个可靠的答案:http://asktom.oracle.com/pls/asktom/f?p = 100:11:2906896739396193::::P11_QUESTION_ID:712625135727
#2
1
That depends on your database. Some databases (for example Postgres, HSQLDB) and their JDBC drivers support anonymous arrays, which you can set with
这取决于您的数据库。某些数据库(例如Postgres,HSQLDB)及其JDBC驱动程序支持匿名数组,您可以使用它们进行设置
Object[] array = // ...
pstmt.setObject(index, array);
Oracle is more complex as it needs a typed object.
Oracle更复杂,因为它需要一个类型化的对象。