public class AddressRowMapper implements ResultSetExtractor<List<Address>> {
@Override
public List<Address> extractData(ResultSet rs) throws SQLException, DataAccessException {
List<Address> addresses = new ArrayList<>();
while (rs.next()) {
Address address = new Address();
address.setCity(rs.getString("CITY") == null ? "" : rs.getString("CITY"));
address.setState(rs.getString("STATE") == null ? "" : rs.getString("STATE"));
address.setZip(rs.getString("ZIP") == null ? "" : rs.getString("ZIP"));
addresses.add(address);
}
return addresses;
}
From: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jdbc/core/ResultSetExtractor.html
rs -从中提取数据的ResultSet。实现不应该关闭这个:它将被调用JdbcTemplate关闭。