File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Returning ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Returning ResultSet" Watch "Returning ResultSet" New topic
Author

Returning ResultSet

Joe Deluca
Greenhorn

Joined: Jan 29, 2009
Posts: 14
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


SCJP 6
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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).


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
Joe Deluca
Greenhorn

Joined: Jan 29, 2009
Posts: 14
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

Joined: Oct 08, 2006
Posts: 2458
You may find this kickoff DAO example useful: http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Returning ResultSet
 
Similar Threads
firtst foray into JDBC/
Novice in JDBC
moving in a ResultSet
not able to establish connection for jdbcodbcdriver
DB connection and a null pointer exception