Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 17346
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.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic