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. DB lost connection after 5 minutes aprox.
Forum Updated to NodeBB v4.3 + New Features

DB lost connection after 5 minutes aprox.

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 384 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.
  • U Offline
    U Offline
    U7Development
    wrote on last edited by
    #1

    Hi!..

    I'm using ODCB for MySQL, and developing a word processor that once user is finished writing it, he saves its contents as .html (QTexEdit to plainHTML) and send to ftp server, that is not a problem at all... but i need to write to my db an ID and a varchar string that handles the url for the document. The problem is that user could take a long time writing the document, lets say 20 minutes more less, in such time the db connection is lost, so when he clicks save, the content will send to ftp but will not be writen the db registry.

    what is the best way to handle this?, how can i set limitess connection time?

    what i tried is to check if connection is alive and is valid everytime i send a query, but those two bools are true even if the connection was gone...

    thanks in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If there's no activity at all with the database during all that time then it would make more sense to open the database connection only when you actually need it.

      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
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        I think its the interactive_timeout setting.

        https://stackoverflow.com/questions/14726789/how-can-i-change-the-default-mysql-connection-timeout-when-connecting-through-py

        but as @SGaist says, if you can wait to open until you need it, its more clean.

        1 Reply Last reply
        2
        • U Offline
          U Offline
          U7Development
          wrote on last edited by
          #4

          thanks for answering... So it is not a problem that i switch between opening and closing db for every query i do?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            No it's not especially if you are doing them infrequently.

            Beware if you are using a QSqlQueryModel or one of its subclasses, you can't do that.

            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
            1

            • Login

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