On 5 Oct 2010, at 1:11pm, Serena Lien wrote: > Yes - that is indeed what I am doing (your 3rd scenario) - but I have tried > to close the connection first (and ignore any errors closing it) before > retrying to open. As you say, the database object I am trying to close may > not be valid so I am not able to close it first, and therefore unable to > open again. Terminating the application obviously allows it to close, so > that restarting my application now successfully opens it.
... and triggers SQLite's routines which spot the journal file and restore the database to a sane state. > So my question is, is there any sqlite function I can call so that the > connection can be successfully closed? So you are doing this: start application sqlite3_open_v2() sleep wakeup // Oh, my open connection is now useless, I need one that works ! sqlite3_close() sqlite3_open_v2() And I would guess that your _close() refuses to function properly, because its file handle is now useless. Unfortunately, the _close() call can only assume that the OS is still in touch with all its files. A programmer has to believe that the OS is sane. And there's no 'close all connections without complaining' command. I can't think of a way to satisfy this inside SQLite, unless you want to have your database open only while you are doing database ops, which will slow things down a bit. In Mac programming an application can ask for notification when the computer is about to sleep and another immediately after the computer wakes up again. You would do that, and put your '_close()' command inside the routine it calls. I don't know what OS you're using but it might have a similar function: the ability to provide a service routine that's called before the computer sleeps. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users