aspose file tools*
The moose likes JDBC and the fly likes moving in a ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "moving in a ResultSet" Watch "moving in a ResultSet" New topic
Author

moving in a ResultSet

kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
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

Joined: Oct 11, 2000
Posts: 1135

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

Joined: Mar 27, 2004
Posts: 120
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: moving in a ResultSet