JdbcTemplate's queryForMap Method error
Improper use of the queryForMap method will make an error, using the following methods:
The queryForMap method in JdbcTemplate is expects a single row to being returned, the return value for this method would be A map of column names to column values for the single result row.
The result set size returned by the queryForMap method must be 1, and the returned map, with the name of the column as the key, gets the value as
Take advantage of Spring's getjdbctemplate (). queryForMap If an empty set is returned, it will be reported
Org.springframework.dao.EmptyResultDataAccessException:Incorrect result size:expected 1, actual 0 exception
try{
Return Getjdbctemplate (). queryForMap ("Select s.fb,s.pb,s.tu,s.qt,s.fbc,s.pbc,s.tt,s.ft,s.lt from Gbc$view_user s where S.ud =? And ad=? ", New Object[]{ud,ad});
}catch (Emptyresultdataaccessexception e) {
return null;
}
Solution in the queryForMap place try catch a bit.
JdbcTemplate queryForMap emptyresultdataaccessexception