Execute a query that results in a long 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 queryForLong
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 a long value.
@param sql SQL query to execute
@return the long 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 #queryForLong(String,Object[])