Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. lost SQL DB connection
Forum Updated to NodeBB v4.3 + New Features

lost SQL DB connection

Scheduled Pinned Locked Moved Solved 3rd Party Software
mysqlqsqldatabaseconnect problem
5 Posts 3 Posters 3.8k Views 2 Watching
  • 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.
  • K Offline
    K Offline
    koahnig
    wrote on 6 Jan 2017, 15:50 last edited by koahnig 1 Jun 2017, 15:50
    #1

    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.

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    1
    • M Offline
      M Offline
      m.sue
      wrote on 6 Jan 2017, 15:58 last edited by m.sue 1 Jun 2017, 16:05
      #2

      Hi,
      there is probably some kind of auto-disconnect by the DB after a maximum connection time or timeout after last write or read.
      -Michael.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 6 Jan 2017, 16:03 last edited by
        #3

        The error message "MySQL server has gone away QMYSQL: Unable to execute query" gives many hits :) and as @m.sue suggests

        http://stackoverflow.com/questions/3615422/mysql-server-has-gone-away

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

        http://dev.mysql.com/doc/refman/5.7/en/gone-away.html

        1 Reply Last reply
        2
        • K Offline
          K Offline
          koahnig
          wrote on 6 Jan 2017, 16:34 last edited by
          #4

          @m-sue @mrjj thanks for your replies.

          The stackoverflow link provides also the treatment. Looks a bit "wooden" ;)

          Vote the answer(s) that helped you to solve your issue(s)

          M 1 Reply Last reply 6 Jan 2017, 16:54
          1
          • K koahnig
            6 Jan 2017, 16:34

            @m-sue @mrjj thanks for your replies.

            The stackoverflow link provides also the treatment. Looks a bit "wooden" ;)

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 6 Jan 2017, 16:54 last edited by
            #5

            @koahnig
            Well the "MySQL server has gone away" msg also seems slightly "wooden" so it fits perfectly :)

            1 Reply Last reply
            1

            1/5

            6 Jan 2017, 15:50

            • Login

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