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. Lost connection in qry->exec()
Forum Update on Monday, May 27th 2025

Lost connection in qry->exec()

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 541 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.
  • Kanni1303K Offline
    Kanni1303K Offline
    Kanni1303
    wrote on last edited by
    #1

    Hi,

    I am using the MySQL database to connect remotely from my application, I check for connection to server before every query exec(), but If I break the connection after the check (i.e on the way executing qry->exec()) my application hangs and not responding any further.
    Here the disconnection is done by me by removing the internet cable.

    How to detect the connection lost during the query execution, if lost how to recover (both the options MYSQL_OPT_RECONNECT=TRUE or MYSQL_OPT_CONNECT_TIMEOUT=10 are not helping) or timeout the connection.

    Thanks,
    Kanni

    Character make's Gentlemen, not appearance.
    --Vivekananda

    JonBJ 1 Reply Last reply
    0
    • Kanni1303K Kanni1303

      Hi,

      I am using the MySQL database to connect remotely from my application, I check for connection to server before every query exec(), but If I break the connection after the check (i.e on the way executing qry->exec()) my application hangs and not responding any further.
      Here the disconnection is done by me by removing the internet cable.

      How to detect the connection lost during the query execution, if lost how to recover (both the options MYSQL_OPT_RECONNECT=TRUE or MYSQL_OPT_CONNECT_TIMEOUT=10 are not helping) or timeout the connection.

      Thanks,
      Kanni

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Kanni1303
      This was discussed at length a while back on this forum (sorry, I don't have the link), and the outcome I believe was you are just not going to be able to detect this or make it timeout. Sorry, if someone else knows better you will have more luck.

      Kanni1303K 1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        I am talking to a print server at port 9100. I cannot tell when it loses connection. So I connect to the webserver the printer has once every 2 seconds and transfer the data (500 bytes). If this transfer fails I disconnect from port 9100 and start trying a reconnect.

        Can you make a dummy second connection (doesn't have to be a database connection, just a port connection) to test if it passes or fails? Then use this result to determine if the original connection is any good.

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0
        • Kanni1303K Offline
          Kanni1303K Offline
          Kanni1303
          wrote on last edited by Kanni1303
          #4

          @fcarney I always detect the internet is good (Ping the server, this verifies route to server is available) before establishing connection to server but the problem is if I disconnect from internet during exec the query, my application hangs and no control. I want to timeout and abort the connection established by qry->exec() and take back application control. what is happening, why application hangs is there any retry count? timeout? error handling?

          Character make's Gentlemen, not appearance.
          --Vivekananda

          1 Reply Last reply
          0
          • JonBJ JonB

            @Kanni1303
            This was discussed at length a while back on this forum (sorry, I don't have the link), and the outcome I believe was you are just not going to be able to detect this or make it timeout. Sorry, if someone else knows better you will have more luck.

            Kanni1303K Offline
            Kanni1303K Offline
            Kanni1303
            wrote on last edited by
            #5

            @JonB i want to timeout and abort

            Character make's Gentlemen, not appearance.
            --Vivekananda

            JonBJ 1 Reply Last reply
            0
            • Kanni1303K Kanni1303

              @JonB i want to timeout and abort

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @Kanni1303
              I know you do. Which is why I explicitly wrote that this has been asked before and the gist is you cannot have one. What else do you want me to say?

              1 Reply Last reply
              0

              • Login

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