Stored procedures call (namedparameterjdbctemplate)

admin

Administrator
Staff member
I'm trying to call a stored procedure using jdbc. My connection is being passed through namedParameterJdbcTemplate and that's what I have to use to call it, but when I attempt to do this:
Code:
public void storedProcedure(long fileId, String Action) {

    String sql = "call procedureName(?)";

    try {
        namedParameterJdbcTemplate.update(sql, Long.valueOf(fileId) );
        
    } catch (Exception e) {
        logger.error("Error while running stored procedure  {}", sql, e);
    }
}
I get the following error:
<blockquote>
Cannot resolve method 'update(java.lang.String, java.lang.Long)'
</blockquote>
Sources I've tried looking at and can't make it work:
<ul>
<li><a href="https://docs.spring.io/spring-framework/docs/4.2.x/spring-framework-reference/html/jdbc.html" rel="nofollow noreferrer">https://docs.spring.io/spring-framework/docs/4.2.x/spring-framework-reference/html/jdbc.html</a></li>
<li><a href="https://lalitjc.wordpress.com/2013/07/02/different-ways-of-calling-stored-procedure-using-spring/" rel="nofollow noreferrer">https://lalitjc.wordpress.com/2013/07/02/different-ways-of-calling-stored-procedure-using-spring/</a></li>
<li><a href="https://www.logicbig.com/tutorials/...s-with-jdbc/spring-call-stored-procedure.html" rel="nofollow noreferrer">https://www.logicbig.com/tutorials/...s-with-jdbc/spring-call-stored-procedure.html</a></li>
</ul>
Most of them are creating a connection from the beginning but I already have it (namedParameterJdbcTemplate), also some are using datasource which I don't need because again, I have already the connection.
How can I make the call with namedParameterJdbcTemplate?
Thank you