Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

result sets

 
ryan bohnert
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class called Client, where I am making a call to another class called DB.

I am passing in a select statement to the DB class, the DB class takes care of the driver, login, connection, statement, result set, and closing work.

But I don't want the DB class to have to loop through the result, i want the client to do this.

So how exactly do i give them the data from the DB class and still maintain doing the closing work. Do i need to put the results set in a collection and return that back to the Client class, so I can still close everything i need in the DB class. I know i have to someone move the data from result set because once it closes it will be gone.

Any suggestions would be great?
 
Kalyani Sailendra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The normal practice is to call the getconnection method of the DB class in the client, do the processing on the resultset and then call the method of DB class to take care of closing the connection or close the connection in the client class.

In your situation, every time the resultset needs to be copied in to a different object and passed to the calling class.
 
Jan Cumps
Bartender
Posts: 2586
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The CachedRowSet allows you to iterate over the results of a query when the database connection is unavailable.
Get disconnected with CachedRowSet.

Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic