Interface RowMapper

public interface RowMapper

An interface used by JdbcTemplate for mapping returned result sets. Implementations of this interface perform the actual work of mapping rows, but don't need to worry about exception handling. SQLExceptions will be caught and handled correctly by the JdbcTemplate class.

Typically used either for JdbcTemplate's query methods (with RowMapperResultReader adapters) or for out parameters of stored procedures. RowMapper objects are typically stateless and thus reusable; they are ideal choices for implementing row-mapping logic in a single place.

Alternatively, consider subclassing MappingSqlQuery from the jdbc.object package: Instead of working with separate JdbcTemplate and RowMapper objects, you can have executable query objects (containing row-mapping logic) there.

Thomas Risberg
See Also:
JdbcTemplate, RowMapperResultReader, MappingSqlQuery

Method Summary
 Object mapRow(ResultSet rs, int rowNum)
          Implementations must implement this method to map each row of data in the ResultSet.

Method Detail


public Object mapRow(ResultSet rs,
                     int rowNum)
              throws SQLException
Implementations must implement this method to map each row of data in the ResultSet. This method should not call next() on the ResultSet, but extract the current values.

rs - the ResultSet to map
rowNum - The number of the current row
SQLException - if a SQLException is encountered getting column values (that is, there's no need to catch SQLException)

Copyright (C) 2003-2004 The Spring Framework Project.