Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] QMYSQL Driver not loadad but available
Forum Updated to NodeBB v4.3 + New Features

[Solved] QMYSQL Driver not loadad but available

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 3 Posters 6.6k Views 1 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.
  • H Offline
    H Offline
    henrikk
    wrote on last edited by
    #1

    Dear Sirs,

    as I try to connect to an existing MySQL Database I get "Driver not loaded" in QSqlDatabase::lastError ().
    The ooutput of QApplication::libraryPaths () is: ("/usr/lib/qt4/plugins", "/home/ernie/src/recipe") which is correct. Most irritable is the output of QSqlDatabase::drivers () which is "("QSQLITE", "QMYSQL3", "QMYSQL")" so it seems that QMYSQL driver should be available. Also I have tried to use Environment variable QT_DEBUG_PLUGINS set to 1 which generates the following output:

    @QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/inputmethods/libqimsw-multi.so"
    keys ("imsw-multi")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/sqldrivers/libqsqlite.so"
    keys ("QSQLITE")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so"
    keys ("QMYSQL3", "QMYSQL")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
    keys ("svg", "svgz", "svg.gz")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqgif.so"
    keys ("gif")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqico.so"
    keys ("ico")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqjpeg.so"
    keys ("jpeg", "jpg")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqmng.so"
    keys ("mng")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqsvg.so"
    keys ("svg")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/imageformats/libqtiff.so"
    keys ("tiff", "tif")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
    keys ("svg", "svgz", "svg.gz")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt4/plugins/iconengines/libqsvgicon.so"
    keys ()@

    This results in two different developement environments, one is debian squeeze (6.0), that is Qt 4:4.6.3-4, and one in an user local directory, which ist Qt 4.7.0 rom source.

    Thank you for your kindness

    Henrik K.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      That is very strange. The listing you post, as well as QMYSQL being in the list of drivers, is really indicative of the driver being loaded successfully. Could you post the code where you create the database connection?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        henrikk
        wrote on last edited by
        #3

        Thanks for your reply. Here is my connection code:
        The error was: I did not see that QApplication::addDatabase () is a static function.

        Thanks for your help.

        Henrik K.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You did not actually post the code, but I gather you managed to fix the problem.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            henrikk
            wrote on last edited by
            #5

            Wrong code was:
            @QSqlDatabase db;
            db.addDatabse ("QMYSQL");@
            which I corrected to
            @QSqlDatabase db = QSqlDatabase::addDatabase ("QMYSQL");@
            This solved the problem.

            Yours
            Henrik K.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              liuxinisbird
              wrote on last edited by
              #6

              it's too strange ,but i have solves this problem luckily ,thank you

              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