permaculture playing cards*
The moose likes Spring and the fly likes Calling Stored Procedure with list of values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Calling Stored Procedure with list of values" Watch "Calling Stored Procedure with list of values" New topic
Author

Calling Stored Procedure with list of values

Chinababu Illa
Greenhorn

Joined: Jun 04, 2008
Posts: 23
Hi All,

I have a requirement like this. I have set of applications (application is a java object). Every application has a set of fields (Field is a java object). Every field has set of attributes. I need to store multiple fields for a specified application at one go.
I have a stored procedure with following signature.


Where FIELDS_TYP is an OBJECT defined as follows. [I removed and renamed some of the fields to make it simple]



This stored procedure can take list of field objects in single invocation.

How should invoke this stored procedure with a list of field objects from java code in single invocation using Spring 3 JDBC module. I am not using any of the ORM tools.
Note: Since I want to write a generic code, I am not supposed to use any of the database specific APIs like ARRAY from Oracle.

Please suggest me some solution.

Thanks,
Chinna
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

Have you read the documentation?

http://static.springsource.org/spring/docs/3.1.x/s...c.html#jdbc-simple-jdbc-call-1
http://static.springsource.org/spring/docs/3.1.x/s...c.html#jdbc-simple-jdbc-call-3
http://static.springsource.org/spring/docs/3.1.x/s...jdbc.html#jdbc-StoredProcedure
http://static.springsource.org/spring/docs/3.1.x/s...l/jdbc.html#jdbc-complex-types

You might also want to take a peek at
http://www.springsource.org/spring-data/jdbc-extensions

And another thread that seems to be doing the same thing here:
http://forum.springsource.org/showthread.php?33053-How-can-i-pass-arraylist-to-stored-procedure


[How To Ask Questions][Read before you PM me]
Chinababu Illa
Greenhorn

Joined: Jun 04, 2008
Posts: 23
Hi Bill,

I have read the documentation, but I didn't completely understand. There is very little information in the documentation about calling stored procedure with list of objects.
But, now my problem is resolved after going though one of your links and the spring documentation together. I could not do it anyway without Oracle's ARRAY and STRUCT types.

What I have actually done is, I created STRUCT object for each set of input values and kept them in ARRAY object and passed this ARRAY object to stored procedure. Now it worked.

For anyone's reference, I am posting complete working code below.



Thanks Bill,


-Chinna
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

Chinna,

Your welcome and thanks for posting back with your solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling Stored Procedure with list of values
 
Similar Threads
Stored Procedure and Java
Inserting data in database having Table Of Objects using store procedure callablestatement
Problem working with Oracle Objects using weblogic database control
How to read object collection as an out parameter of stored procedure(Oracle)?
Oracle custom object from java