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.
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.