• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object created from a result set.  RSS feed

 
John Paterson
Ranch Hand
Posts: 173
  • 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
Rancher
Posts: 2914
36
  • 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())).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!