Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Result Set

 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings everyone,
When i try to print the result, it only prints first row even though it has multiple rows.What am i doing wrong here.

 
Scott Selikoff
author
Saloon Keeper
Posts: 4008
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gotta say I'm not familiar with your strategy here... why aren't you just using the common practice of iterating over a result set with a while loop?
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Tome,

your example is from http://jakarta.apache.org/commons/dbutils/examples.html,
right?

Just look at the text below the example:
"In the examples above we implemented the ResultSetHandler interface to turn the FIRST row of the ResultSet into an Object[]."

If you want to display all rows, just use one of the other resultsethandlers that DBUtils has(BeanListHandler looks OK to me).

Herman
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tome Wagese:

When i try to print the result, it only prints first row even though it has multiple rows.


what the java Docs Says :
A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set
 
Tome Wagese
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic