[Qt-interest] QSqlDatabase
Rick Vernam
rickv at hobi.com
Wed Dec 10 18:58:12 CET 2008
On Wednesday 10 December 2008 11:45:56 am Diego Schulz wrote:
> On Mon, Jan 7, 2008 at 8:01 PM, Rick Vernam <rickv at hobi.com> wrote:
> > At some point after connecting to a Postgresql database via QSqlDatabase,
> > I cause an unexpected disconnect (ie, pull the ethernet cable from the
> > computer).
> > After that, I check database->isOpen(), and it says true.
> > So, I try to database->exec(some_query), and it hangs (for at least 2-3
> > minutes, perhaps longer).
> >
> > what is the preferred method of:
> > 1 - identifying database disconnect
> > 2 - prevent QSqlDatabase::exec(...) from hanging
> >
> > Of course one option is to create a threaded wrapper class.
> > Other ideas?
> >
> > Thanks
>
> Hi,
>
> I was trying to figure out a clean way to detect database disconnects
> (obviously is only relevant when connecting to remote databases). I'm using
> PostgreSQL and my client application connects over a poor link (ie wifi).
> Eventually the connection is lost causing the application to become
> unresponsive as described by Rick.
>
> Anybody there can suggest a way to detect and react database disconnects?
>
> Thanks in advance!
By the way, I was not able to find a nice way to detect disconnects.
I ended up just wrapping DB stuff in a threaded class. I use signals & slots,
obviously...
More information about the Qt-interest-old
mailing list