I received the following error from the code that calls a stored procedure from java code:
Exception Trace {} org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call test.usp_xxx_GetCompanyDetails(?, ?, ?, ?, ?, , ?, , ?, ?, ?, ?, ?)}]; SQL state [null]; error code [0]; The value is not set for the parameter number 11.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 11. at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1095) at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1131)
The application is deployed on WAS 8.5.5 and using jdbc driver version 4.2. On restarting the server this issue did not occur again. The following call statement generated looks to be incorrect. There are consecutive commas without ? between them.
{call test.usp_xxx_GetCompanyDetails(?, ?, ?, ?, ?, , ?, , ?, ?, ?, ?, ?)}
The stored procedure has 10 parameters. Following is the definition of the stored procedure:
CREATE PROCEDURE [test].[usp_xxx_GetCompanyDetails]
(
@ANumber int,
@CompanyId int,
@UserRole varchar(15),
@RequestId varchar(100),
@CompanyCode varchar(5),
@BaseSystem varchar(5),
@PType varchar(20),
@PId varchar(40),
@IsActive bit,
@responseData xml OUT
)
Following is the java code that makes a call to the stored proc. It is using spring data to make the call.
private String executeProc(Integer aNumber,Integer companyId, String baseSystem,
String role,String companyCode,String requestId, String pType,String pId,
boolean isActive ) throws SQLException {
SQLXML responseData=null;
Map<String,Object> inputParams= new HashMap<>();
inputParams.put("ANumber", aNumber);
inputParams.put("CompanyId", companyId);
inputParams.put("UserRole", role);
inputParams.put("RequestId", requestId);
inputParams.put("CompanyCode", companyCode);
inputParams.put("BaseSystem", baseSystem);
inputParams.put("PType", pType);
inputParams.put("PId", pId);
inputParams.put("IsActive", isActive);
inputParams.put("ResponseData", responseData);
Map<String, Object> result = this.execute(inputParams);
String responseXMLString = ((SQLXML) result.get("ResponseData")).getString();
return responseXMLString;
}
What could have gone wrong.
?markers, so two of the parameters are undefined. The error message indicates that you're not setting value for the 11th marker, i.e. not callingsetXxx(11, xxx). No wonder the JDBC driver is confused about what you're trying to do here. - Andreasthis.execute()in the code sample, and theJdbcTemplate.call()in the stack? The first parameter toJdbcTemplate.call()is aCallableStatementCreator, which is usually an immutableSimpleCallableStatementCreatorbased around aString. It sounds like this could be something different here? - df778899