• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RowMapper callback interface's mapRow can pull only one row?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

This is just to check RowMapper callback interface's mapRow(ResultSet rs, int rowNum) can pull only one row??/

Thanks,
Vineet
 
vineet kaushik
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Guess, I have got the answer of my question .. I was using queryForObject(arg1,arg2,arg3) method of JDBC template instead of query(arg1,arg2,arg3) method of JDBC template.... RowMapper callback interface can pull multiple rows..

Please fell free to improve above mentioned answer.

Thanks,
Vineet
 
vineet kaushik
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is code to pull multiple rows using Rowmapper and jdbcTemplate.query(arg1,arg2).

Collection emp=jt.query("select * from employee", new RowMapper()
{
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Employee e=new Employee();
e.setFirstName(rs.getString("first_name"));
e.setLastName(rs.getString("last_name"));
e.setAge(rs.getInt("age"));
e.setEmail(rs.getString("email"));
e.setEmpno(rs.getInt("empno"));
return e;
}
});
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to loop through the result set yourself, then you should use the ResultSetExtractor interface instead of RowMapper.

Mark
 
vineet kaushik
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct Mark,

Thanks for sharing your knowledge..

Thanks,
Vineet
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vineet kaushik wrote:Correct Mark,

Thanks for sharing your knowledge..

Thanks,
Vineet



Hi all,

I have 2 classes (Role and User) and I want to create 1 row mapper class for both classes.

Is it possible?

Thanks in advance,
Geeta
 
Geeta Puttappanavar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Geeta Puttappanavar wrote:

vineet kaushik wrote:Correct Mark,

Thanks for sharing your knowledge..

Thanks,
Vineet



Hi all,

I have 2 classes (Role and User) and I want to create 1 row mapper class for both classes.

Is it possible?

Thanks in advance,
Geeta



Resolved. Spring provides BeanPropertyRowMapper class. By using this we can achive.
 
See where your hand is? Not there. It's next to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic