Image

Imageex_simanyay wrote in Imagejava_dev 🤓geeky

Listens: Gorillaz - Rock The House

ResultSet and Statement live cycles

Hello. I've created a class that executes SQL queries and then returns ResultSet object if needed. My Connection object is in the class scope, but Statement is in the method scope. And now I've a problem, because ResultSet object, that I've returned, goes to isClosed() == true state after Statement object is deleted (when method ends). I've two three ways to solve this problem in my mind:
1. Put Statement into the class scope, but then I'll have new problem. If user will decide and store ResultSet object, he/she will not be able to execute new query, because ResultSet will go to isClosed() == true after the new query execution.
2. Create a pool of Statement objects. But how will I know, when I should delete some object?
3. Create new data structure that will act like ResultSet, but will be independent to Statement object.

Can anyone suggest anything?

Thanks a lot.

- sim

P.S. Sorry for my english :-(