• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

moving in a ResultSet

 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a GUI window which lets users to enter a staff number.
then it shows some data from the database.

when a user click on the button "next", it should show the next data
that matches the staff number (in other words, the data in the ResultSet).

here is my code :

(ResultSet rs is defined as a global variabel in the same class)

the problem is that when i press "next", it does show the next data.
but when i then once again click "next" again,
nothing happens.

why is that?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kelvin,
Method "next()" of interface "java.sql.ResultSet" returns a boolean. Perhaps you have reached the end of your "ResultSet". Also, your error handling code simply prints "Error" on the console. Since you are using a GUI, perhaps you forgot to look at the console to see if "Error" is getting displayed?

Perhaps your code should be something like:

And remember to check the console for error messages.
Of-course, I think there are better ways of informing
the user (of your GUI application) that an error has
occurred, but I think that is beyond the scope of your
question. (Maybe you could try the Swing forum?)

Good Luck,
Avi.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Avi,
I know that the that the next method returns a boolean ..
And I have tried to check the console. But cant see "error".

This is the code for the GUI button which calls the method which I posted earlier.



These are the methods in the GUI class.

ResultatVO resultat; defined as global variabel.
Hmm?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic