Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-17140

QMYSQL/QSqlDatabase isOpen()/isValid() returns true even if connection is lost

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.6.3
    • SQL Support
    • None
    • Debian GNU/Linux, testing, 6.0, amd64 architecture.

    Description

      Hello.

      I'm using Qt, version 4.6.3, and QMYSQL driver.

      My application is connecting to database once, when constructing database worker object.
      When connection is lost (for ex. MySQL server restarted), QSqlDatabase methods isOpen(), isValid() return TRUE instead of FALSE.
      lastError() returns QSqlError::NoError, even after unsuccessfully executing query (empty QSqlQuery as the result).

      The only solution I found was executing simple "SELECT 1;" and checking if query.first() returns false and invoking QSqlDatabase::open() again.
      But this solutions requires running additional query every time.

      Sorry if this problem has been fixed in later Qt versions, but I'm not able to check that at the moment, or if I'm misinterpreting something.

      Best regards,
      Grzegorz B.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            grzesiekb Grzegorz Bizon
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes