Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Difference between RowCallbackHandler and RowMapper

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is difference between RowCallbackHandler and RowMapper?
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic