I'm cleaning up a very poorly done, large, webapp. I can't do it all at once, so I am taking it in pieces. One thing I would like to do is implement a class with functions that take SQL statements and then returns a collection. My plan is once that is taken care of I can shop around for a database framework to replace that layer without disturbing the rest of the webapp.
The big problem with returning a ResultSet out of template style database access function is that I can't close the connection without disabling the ResultSet.
I was excited to find the suggestions in this old stackoverflow post.
I read the article cited on CachedRowSet, but I am concerned where the article stated its use could create a problem with sucking up a lot of JVM memory by stuffing a large amount of results into itself.
Wouldn't the alternative Apache ResultSetDynaClass or any other Collection have the same problem? The results have to get written into memory one way or the other. Right?
If I used ChaedRowSet, ResultSetDynaClass or a Java Collection to store ResultSet data, would I lose that data once I closed the ResultSet?
I've used HashMaps to store single records from generic database query functions.
How could I use java Collections to store multiple records without the code getting cumbersome? Assuming that I could, would it be more resource efficient or flexible than the other two options?
Thanks in advance for any information or ideas.