Execute a query that results in an int value, given static SQL.
Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt
method with null
as argument array.
This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in an int value.
@param sql SQL query to execute
@return the int value, or 0 in case of SQL NULL
@throws IncorrectResultSizeDataAccessException if the query does not returnexactly one row, or does not return exactly one column in that row
@throws DataAccessException if there is any problem executing the query
@see #queryForInt(String,Object[])