Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
auto reconnect to sql-database on connection loss
themts last edited by
I have an application which is connected 24/7 to a MS-SQL database.
If for some reason the connection is gone (i.e. server-restart) the client is woring anymore.
Is there a global method to detect a lost connection and to restart it?
I don't want to handle every execute statement individually.
You should add which driver you are using to connect to that database as well as OS and Qt version.
themts last edited by themts
I'm using the odbc-driver for linux (FreeTDS).
hskoglund last edited by
Hi, I had more or less the same problem, and instead of trying to keep the connection alive to the server, I resorted to a polling approach, i.e. say every 5 minutes, I'd close all active connections, close the database, open the database again and reestablish the queries (this depends of course how often you can accept loss of contact, for example a heartbeat-monitor in a hospital, in this case 5 minutes is not acceptable).