org.springframework.jdbc.core
Interface RowMapper

All Known Implementing Classes:
ColumnMapRowMapper, SingleColumnRowMapper

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.

Author:
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

mapRow

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.

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


Copyright (c) 2002-2005 The Spring Framework Project.