Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between RowCallbackHandler and RowMapper

 
Neha Sen
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is difference between RowCallbackHandler and RowMapper?
 
aresh babu
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both RowCallBackHandler and RowMapper are both for retrieving the results from a ResultSet which takes the responsibility to process each row of data in the ResultSet. Both interface methods should not call next() on the ResultSet. It requires to extract values of the current row and process the data on per-row basis.

RowCallBackHandler's processRow(ResultSet rs) does not return object which is having the result.If require it can store the result in its instance variable and then make it available it to DAO but for this it requires to be designed as stateful.
So this type of method(processRow()) is generally implemented to process the result like preparing XML document with the result data.

But RowMapper's mapRow(ResultSet rs, int rowNum) can return an Object representing the result object for the current row.
In general this interface is designed as stateless to make it reusable and reduce the memory requirements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic