File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Call stored procedure with Spring 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 » Other Application Frameworks
Bookmark "Call stored procedure with Spring" Watch "Call stored procedure with Spring" New topic
Author

Call stored procedure with Spring

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
I have a stored procedure with 1 parameter (INOUT DECIMAL).
My class extends Spring framework StoredProcedure class. It errors at line:

Map outParams = execute(inParams);

java.sql.SQLException: The number of parameter values set or registered does not match the number of parameters.

The code is as follows:



BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
Found out it must be:

declareParameter(new SqlOutParameter("P1", Types.DECIMAL));

instead of:

declareParameter(new SqlParameter("P1", Types.DECIMAL));
Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
(Blatant advertisin not allowed in this forum, and please don't resurrect months old threads. - Mark Spritzler)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call stored procedure with Spring
 
Similar Threads
Spring-RowMapper-DB2-Stored Procedure
Calling Stored Procedures from Spring
How to call StoredProcedure with mixed input data types?
RowMapper & Stored Proc @ DB2
StoredProcedure on a DBLink.