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 to MySQL server during query QMYSQL3: Unable to reset statement
Forum Update on Monday, May 27th 2025

Lost connection to MySQL server during query QMYSQL3: Unable to reset statement

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.3k 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.
  • C Offline
    C Offline
    Chrisw01
    wrote on 11 Oct 2019, 21:33 last edited by
    #1

    Hi, I am experiencing a problem I'm not sure how to trace. I receive the above error about 500 records into an import from my Qt: App. I've downloaded the latest Qt for Windows. Used several different versions of mysql server on linux on several different machines with the same outcome. I've found references to timeouts on the internet but usually its after hours. I can make this fail in seconds.

    OS Windows 10. Qt 5.12.5. Mysql Server both 5.x series and 8.x series. Latest MariaDB server. doesn't matter same thing after bout 500-600 records.

    Any ideas on where to point me to?

    J 1 Reply Last reply 12 Oct 2019, 08:43
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 12 Oct 2019, 06:18 last edited by
      #2

      Can you show use some code?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • C Chrisw01
        11 Oct 2019, 21:33

        Hi, I am experiencing a problem I'm not sure how to trace. I receive the above error about 500 records into an import from my Qt: App. I've downloaded the latest Qt for Windows. Used several different versions of mysql server on linux on several different machines with the same outcome. I've found references to timeouts on the internet but usually its after hours. I can make this fail in seconds.

        OS Windows 10. Qt 5.12.5. Mysql Server both 5.x series and 8.x series. Latest MariaDB server. doesn't matter same thing after bout 500-600 records.

        Any ideas on where to point me to?

        J Offline
        J Offline
        JonB
        wrote on 12 Oct 2019, 08:43 last edited by
        #3

        @Chrisw01
        Unfortunately, https://forum.qt.io/topic/13442/qmysql3-unable-to-reset-statement reports the same from 2012 and received no replies :(
        https://kde-pim.kde.narkive.com/b6Avv5nE/long-running-app-loses-mysql-connection reports similar-ish, claimed resolution:

        using setConnectOption("MYSQL_OPT_RECONNECT=1") should automatically restore the connection if it's lost.

        Source code of error:
        https://code.woboq.org/qt5/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp.html, line #1012.

        1 Reply Last reply
        2
        • C Offline
          C Offline
          Chrisw01
          wrote on 14 Oct 2019, 18:23 last edited by
          #4

          Thanks for your input.

            I've changed the way I handle the database entries getting away from QSqlQuery::prepare() by building a string and calling QSqlQuery::exec() with the string. I get to about 1200 records before the time out however, after a moment or two the program continues to add entries into the database.
          

          @JonB Yea, I found that as well as a couple of other references on the net but no outcomes or fixes mentioned.

          @Christian-Ehrlicher I will post some code when I get back to my office later on.

          Thanks again ...

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chrisw01
            wrote on 24 Oct 2019, 15:59 last edited by
            #5

            Not quite sure if this is a bug or not, but I've changed the offending code to call QSqlQuery::exec() with a pre-built string instead of using QSqlQuery::prepare(). I've wrapped ::exec in a timed while loop until either timeout or positive completion. It will timeout but after a few moments it continues to process just fine. It seams ::prepare() simply gives up and throws the reset error.

            Any other Ideas?

            1 Reply Last reply
            1
            • C Offline
              C Offline
              Chrisw01
              wrote on 26 Oct 2019, 14:55 last edited by
              #6

              The above method introduced another issue. Apparently bindValue escapes the special characters. I've looked for a function or example on how to do this manually without luck. Does anyone know if such function exists ?

              1 Reply Last reply
              0
              • J JonB referenced this topic on 25 Oct 2023, 06:49
              • J JonB referenced this topic 4 days ago
              • M mvsri referenced this topic 4 days ago

              • Login

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