Rowsets and database close

Closing an SQLitedatabase appears to close rowsets from this database too. Is this intentional?

Most probably yes.

Hmmm, too bad. Didn’t do that with recordSets.

Report it please. Just to be sure. Because if RecordSets did not, RowSets should behave the same.

recordsets should have since row sets are just recordsets renamed not a completely new implementation

it could have been a bug that they didnt with recordsets

I would not rely on them being open once the db has closed as there are some db’s where the recordset may not exist entirely in memory and it MUST be connected to an open database connection

this would just make things consistent between various dbs

My habit was always been to close the db as soon as I had the RecordSet that I needed. Doing this with RowSets gives an UnsupportedOperationException as soon as I try to use the Rowset results.

I would not expect a rowset to remain opened
I’ve never expected a record set to and that it did might actually have been a bug

I think that the best bet you can do if you want to keep a “snapshot” of a RecordSet / RowSet on memory is replicating them on a Data Structure you can keep control of; for example a Dictionary or your own class can do the trick…

That way, if you really need to close the DB connection as soon as possible… then you still can work with your data structure instances (maybe updating their contents), and once you’re ready to operate against the database you can Open the connection again.

Would that help?

I don’t actually need, generally, to close the db as early as I do. It’s just a habit, and if the rules change I’ll have to change too. I suspect Norman’s right about this: [quote=457393:@Norman Palardy]I would not expect a rowset to remain opened
I’ve never expected a record set to and that it did might actually have been a bug[/quote] and they fixed it when defining RowSet.

But it must be more than a simple name change (RecordSet -> RowSet), as my app actually started up OK once I’d fixed all the tooltip stuff - but before I’d changed everything to RowSet. It was that step that exposed this close() business.

theres simply no way they rewrote all the db stuff since the spring
now it may be that there is some additional code in rowset that checks to see the db it originated from is open or not

What I’m actually finding is that if you close the database and then try to use the RowSet results, it sometimes works, and sometimes gives you an Exception.

I would avoid trying to do that at all

Oh I am. I’m going through and moving all the db.close() to better spots. But I run the app and it works so I imagine I’ve found them all. Then on next run I get an exception in code that was OK in the previous run. That is, it should have exceptioned previously - but didn’t.

In my apps, I never close the database (SQLite) until I’m absolutely sure I’m done with it, which is usually when I’m closing the app. I have never run into the necessity for it. As for the RowSets, I close them immediately after I have harvested the data from them, and certainly before they go out of scope. I come from the old school where we were taught to always close anything you opened.