Also, if you mean you don't know the number of items you retrieved, then its simple. Get an iterator and use its hasNext method to determine if there is another object after the current pointer. If there is, then use the next() method in a loop to retrieve the object and keep adding in a collection. Also, if you dont want to use iterator, use the resultset.next method, and keep adding the object returned in a Collection till rs.next() returns false i.e. no more records left.