• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object created from a result set.

 
John Paterson
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I have a question regarding an object that is created based on a resultset.

Let's say I have a product DAO class:



My question is this, let's say the sql query return 5 rows as a result, what than does the product object finally contain, does it only contain the values of finally returned row, in this case the 5th row? Hope someone can advise.
Thank you.







 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your case it only contains the first row returned, returned by the one call to next().
If you want all the rows then you need to build a List<Product> and iterate over the ResultSet (while(products.next())).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic