Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
lost SQL DB connection
koahnig last edited by koahnig
I have an application writing into a table frequently. In general it does its job sufficiently and shall 24/7. In the mean time I have experienced twice a loss of connection to the DB.
When starting to write a class to safe-keep the connection details I realized QSqlDatabase may be used to retrieve the essential information and reopen.
The error message received is:
MySQL server has gone away QMYSQL: Unable to execute query
In order to prevent the problem for happening again I plan to setup up a handler. I am wondering now if a simple open to the DB shall be enough?
But on the other hand this could be already handled internally.
In the doucmentation I could find anything explaining the suituation. Did I run into a very uncommon problem?
Restarting the application again was sufficient to cure the problem. Therefore, I do not expect an external DB problem.
m.sue last edited by m.sue
there is probably some kind of auto-disconnect by the DB after a maximum connection time or timeout after last write or read.
The error message "MySQL server has gone away QMYSQL: Unable to execute query" gives many hits :) and as @m.sue suggests
"By default, the server closes the connection after eight hours if nothing has happened. You can change the time limit by setting the wait_timeout variable when you start mysqld."
koahnig last edited by
The stackoverflow link provides also the treatment. Looks a bit "wooden" ;)
Well the "MySQL server has gone away" msg also seems slightly "wooden" so it fits perfectly :)