File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exhausted result set

 
James Morrision
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello i have a problem in my java program which connects to a database. With my next button it will go through all the records in my table one time but when it comes back around i get an exhausted result set. Here is a copy of my code. I would be grateful for any help on this. thanks.


 
Scott Selikoff
author
Saloon Keeper
Posts: 3887
15
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to loop back around you need to run the query again.
 
James Morrision
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would this be done do you know by any chance. Sorry now I am not the best at Java...still in college.
 
Scott Selikoff
author
Saloon Keeper
Posts: 3887
15
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strictly speaking Result Sets are not held in memory. It's completely possible every time you call next() its going to the database and asking for the next row. Although most databases have a fetch size (send 10 at once for example), imagine you have a million records, there'd be no way to send them all at once. In other words, by the time the database has reached the end of the result set, it's done. You need to re-run the query get the data again since the data may have changed. (There are *some* database drivers that let you move around ResultSets but since they are not standard I prefer to ignore their existence)

Also, I'm not seeing where in your code you are executing the query. It seems like you jump from creating a connection to reading the results. Perhaps you should review some JDBC tutorials.
 
James Morrision
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay cheers thanks for your help.
 
James Morrision
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to let you know I execute a query when the jframe loads and it sets all the text boxes with the information from the first record in the database.
 
James Morrision
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it going thanks for your help. I just put in an if satement to check if the result set had a next item. If it didnt i just executed the query that i did when the program loads. Probably not the best way of doing it but its going, thats good enough for me at this time.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic