This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning ResultSet

 
Joe Deluca
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone, I am stuck on a little problem that I cant seem to figure out.

I'm writing a program to add, update and remove from a mySQL database. I would like to return my ResultSet in my data access class to my GUI class to display the data.
But the returned resultset always seems to be empty..

DataAccess Class


GUI Class


Any ideas...?

Thanks,
Joe
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should never pass connection, statement or resultset outside the block where they are been obtained. You should always acquire AND close them all in the shortest possible scope. If you want to return the results from the query, then you need to map the resultset to a collection of model objects (javabeans, DTO's, VO's, POJO's, or whatever you want to call it).
 
Joe Deluca
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, I am not too familiar with model objects. Could your please give a small example or if you know a good site that explains it.

I need to display data for ResultSets that contain single and multiple rows. for example i need to extract just the first name attribute of a record in a table of one person.

Thanks,
Joe.

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may find this kickoff DAO example useful: http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic