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. Problem with connecting to postgres database
QtWS25 Last Chance

Problem with connecting to postgres database

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.0k 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.
  • R Offline
    R Offline
    rafzio
    wrote on last edited by
    #1

    I'm newbie, and I'm trying to connect to postgres databes with following code:
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("127.0.0.1");
    db.setPort(5432);
    db.setDatabaseName("test");
    db.setUserName("kirk");
    db.setPassword("captain");
    bool ok = db.open();
    QSqlError err=db.lastError();

    I can't open the connection, I get following output:

    First-chance exception at 0x76fb1d82 in qttest1.exe: 0xC0000138: Ordinal Not Found.
    'qttest1.exe': Unloaded 'C:\Qt\5.2.0\msvc2010\plugins\sqldrivers\qsqlpsqld.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libpq.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\wsock32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\ssleay32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\shfolder.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\krb5_32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libintl-2.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libiconv-2.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\libeay32.dll'
    'qttest1.exe': Unloaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll'
    'qttest1.exe': Unloaded 'C:\Windows\SysWOW64\comerr32.dll'
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

    It seems, that a dll leaks a function. I'm using QT 5.2.0 on Windows 7 Pro. What can I do to get the simple method working?

    with regards

    Rafal Ziolkowski

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

      Hi and welcome to devnet,

      Just an educated guess, are you sure your postgresql dlls are all up to date ? Or at least the same used to compile the plugin ?

      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
      0
      • R Offline
        R Offline
        rafzio
        wrote on last edited by
        #3

        hallo,
        I didn't compile the plugin, I did download an exe and I've installed it. How could I compile it? I'm using Visual Studio 2010.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rafzio
          wrote on last edited by
          #4

          Meanwhile I've discovered, that there is a lacko qt5core.dll and qt5sql..dll. I've copyied them into folder with drivers but now I get exception:
          "Unhandled exception at 0x6659a0fb (Qt5Cored.dll) in test.exe: 0xC0000005: Access violation writing location 0x00000004" while executing QSqlDatabase mydb=QSqlDatabase::addDatabase("QPSQL");
          It occurs in qglobalstatic.h in line: Type *operator()() { if (isDestroyed()) return 0; return innerFunction(); }

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

            "Here":http://qt-project.org/doc/qt-5/sql-driver.html#how-to-build-the-qpsql-plugin-on-windows is the building documentation.

            However, there's something fishy in your system, why do you have all these dlls in sysWOW64 ? It's not their place

            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
            0
            • R Offline
              R Offline
              rafzio
              wrote on last edited by
              #6

              WOW64 because it should be a 32-bit application. I'm using Windows 7 professional 64-bit. Thanks for the link to documentation

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

                Still, it's a system folder, so every application that might use one of these libraries might end up loading these rather that the one that they are shipping and the versions might mismatch thus creating various problem and maybe that's what is hitting you

                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
                0

                • Login

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