Announcement Announcement Module
Collapse
No announcement yet.
SimpleJdbcCall + SQL Server + Stored procedure, problem with in params Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleJdbcCall + SQL Server + Stored procedure, problem with in params

    Hi,

    I am trying to call an SQL Server stored procedure that requires params but I always get this error:

    java.sql.SQLException: Procedure or function 'mySP' expects parameter '@param1', which was not supplied.

    Here is the java code:

    Code:
    private SimpleJdbcCall mTemplate;
    private final String PARAM1 = "param1";
    	
    public void setDataSource(DataSource pDS) {
    	mTemplate = new SimpleJdbcCall(pDS)
    		.withCatalogName("dbo")
    		.withProcedureName("mySP")
    		.useInParameterNames(PARAM1)
    		.declareParameters(new SqlParameter(PARAM1, Types.INTEGER))
    		.returningResultSet("results", new MyResultMapper());
    }
    	
    public MyResults search() {
    	MyResults oResult = new MyResults();
    	SqlParameterSource oParams = new MapSqlParameterSource()
    		.addValue(PARAM1, 46);
    	Map<String, Object> oMapResults = mTemplate.execute(oParams);
    	...
    	return oResult;
    }
    Thanks!

  • #2
    So it looks like I have to add .withoutProcedureColumnMetaDataAccess() to the template to make it work.
    But I am confused because I thought that we could avoid using:
    Code:
    .withoutProcedureColumnMetaDataAccess()
    .useInParameterNames(...)
    .declareParameters(...))
    if we respect the stored procedure parameter names in the MapSqlParameterSource we pass to the execute method, what I am doing. I don't know why it requires all this stuff...

    Comment

    Working...
    X