File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Call stored procedure with Spring" Watch "Call stored procedure with Spring" New topic

Call stored procedure with Spring

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 672
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:

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: 672
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: 121
(Blatant advertisin not allowed in this forum, and please don't resurrect months old threads. - Mark Spritzler)
I agree. Here's the link:
subject: Call stored procedure with Spring
jQuery in Action, 3rd edition