Reputation: 5846
I've a Microsoft and Sybase stored procedures that return result as "return @value". I need to read the value from Java via SimpleJdbcCall.
Is it possible?
Upvotes: 2
Views: 4799
Reputation: 10359
Use the SqlOutPutParameters :)
Here is an example :
SimpleJdbcCall countryProcedure = new SimpleJdbcCall(dataSource)
.withoutProcedureColumnMetaDataAccess()
.withProcedureName(procedureName)
.declareParameters(new SqlOutParameter("RETURNCODE", Types.INTEGER))
.declareParameters(new SqlOutParameter("RETURNMSG", Types.VARCHAR));
Map result = countryProcedure.execute();
System.out.println("RETURNCODE: " + result.get("RETURNCODE"));
System.out.println("RETURNMSG: " + result.get("RETURNMSG"));
Edit : I looked at it and there is a simpler way. Use the WithReturnValue() on your SimpleJdbcCall and the return value will be stored in the return Map under the "return" key.
Upvotes: 5
Reputation: 308763
Spring has supported stored procedures nicely since 2.x:
http://static.springsource.org/spring/docs/2.0.x/reference/jdbc.html
These should be able to sort you out.
Upvotes: 0