I am debating whether or not to create a function that will return a ResultSet. Is this something that is acceptable or is it bad practice?
posted 14 years ago
It shouldn't be a problem as long as you are sure that you close the ResultSet after using it. But, I think a better ways is to convert the ResultSet to a List or array of objects that encapsulate the data that is in the ResultSet and return that List (or array). That way, the client class does not have to care about the details of ResultSet closing and it even doesn't need to know that the data is coming from a relational database.
things can get very messy if you start to throw ResultSets around, especially between classes or on high traffic applications. Your objective should be to minimize stress on the database, so you should have a "get in, and get out" type attitude. As mentioned above, store it in an object/collection that best suits your needs to process the results. Jamie
That new kid is a freak. Show him this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads