Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. auto reconnect to sql-database on connection loss
Forum Update on Monday, May 27th 2025

auto reconnect to sql-database on connection loss

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 513 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    themts
    wrote on 8 Mar 2020, 18:48 last edited by
    #1

    Hey guys,

    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.

    THX
    mts

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Mar 2020, 18:53 last edited by
      #2

      Hi,

      You should add which driver you are using to connect to that database as well as OS and Qt version.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        themts
        wrote on 8 Mar 2020, 18:54 last edited by themts 3 Aug 2020, 18:55
        #3

        I'm using the odbc-driver for linux (FreeTDS).
        QT 5.12

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hskoglund
          wrote on 8 Mar 2020, 19:16 last edited by
          #4

          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).

          1 Reply Last reply
          0

          1/4

          8 Mar 2020, 18:48

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved