The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Paul Clapham wrote:Welcome to the Ranch, Sean!
I see that your code prints data from every record, just like you said. But I don't understand what you want instead.
For example, what's a row? Is that the same as a record? And a field? Is that the same as a column from the database table?
And you say you want to see things one at a time. Would you want to see one thing each time you press the Start button or are there other buttons involved?
Tim Holloway wrote:You're saying "if rs.next()" when I think you mean "while rs.next()".
But be aware that while looping/printing is fine for proving the retrieval logic, GUI systems like Swing don't just "write to the display". You'll have to capture what you read in a Model and Swing will display and refresh itself from that model.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Sean Torongeau wrote:When I use "while (rs.next()): all my records print to the console. That is 276 records printing out all at once. I want the printing and therefore the populating of fields to stop at one record. The 276 records is only a temporary database, the real one holds over 200,000 records.
Paul Clapham wrote:
Sean Torongeau wrote:When I use "while (rs.next()): all my records print to the console. That is 276 records printing out all at once. I want the printing and therefore the populating of fields to stop at one record. The 276 records is only a temporary database, the real one holds over 200,000 records.
Well, that's what's happening. You click Start and you see one record.
But that isn't what you said you wanted earlier. At least I don't think it was, my impression was that you wanted to see the records "one at a time". So it seems like you want to have some kind of gap between seeing Record 1 and Record 2, and so on. Is that right? If so, how should that gap work? Wait X seconds before showing the next record? Have the user click the Next button to see the next record?
Although... if you have hundreds of thousands of records, a design which shows them all to the user (whether all at once or one at a time) is basically impractical.
Carey Brown wrote:As I said, you have two 'rs' variables, one a local variable and one a member variable. This is an accident waiting (or more likely already) happened.
Carey Brown wrote:Please post your updated code. Also, you never did show us the button code so we can only imagine what happens when you click on a button.
Carey Brown wrote:The only place you pull out individual fields from your ResultSet is in your doConnect() method. This gets back to what I said about trying to use 'rs' outside of the method.
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|