1

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

3
  • What database? Arrays and stored procedures are a tricky topic when it comes to handling them with JDBC. Also, are you just using plain JDBC, or some sort of abstraction, such as JPA? Commented Jul 18, 2011 at 13:05
  • Which data base do you use. For PL/SQL I think you can find an answer here asktom.oracle.com/pls/asktom/… Commented Jul 18, 2011 at 13:06
  • And please add the signature of the stored procedure as well. Commented Jul 18, 2011 at 13:06

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

1

That depends on your database. Some databases (for example Postgres, HSQLDB) and their JDBC drivers support anonymous arrays, which you can set with

Object[] array = // ...
pstmt.setObject(index, array);

Oracle is more complex as it needs a typed object.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.