Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does SimpleJDBCTemplate.queryForInt do when the database returns null?

What does SimpleJDBCTemplate.queryForInt do when the SQL query's actual result is null?

In particular, what happens if I run queryForInt("select max(foo) from f") and f has no rows?

While I'm on this subject, what happens if I run queryForInt("select foo from f") and f has no rows?

like image 283
Ken Bloom Avatar asked Jun 24 '10 16:06

Ken Bloom


1 Answers

If the query returns null, the queryForInt method will return 0. However, if the query returns no rows, or returns more than one row, queryForInt will throw an IncorrectResultSizeDataAccessException.

Source

like image 119
Jacob Mattison Avatar answered Nov 02 '22 08:11

Jacob Mattison