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.
posted 2 years ago
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())).