Skip to content

Exception in thread “main” org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0

EmptyResultDataAccessException is thrown when a result was expected to have at least one row (or element) but zero rows (or elements) were actually returned. This is a data issue. To handle this you may just catch this exception and return a proper response.

public Employee find(int employeeId) {
	Employee movie = null;
	try {
		movie = jdbcTemplate.queryForObject(
				"SELECT * FROM ret_employees where emp_id = ? ",
				new Object[] { employeeId }, new BeanPropertyRowMapper<Employee>(
	} catch (EmptyResultDataAccessException e) {
		return null;
	return movie;
See also  How to increment date by one day in Java?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.