• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

moving in a ResultSet

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic