Problem with connecting to postgres database
-
wrote on 29 Jan 2014, 15:05 last edited by
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 QPSQL7It 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
-
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 ?
-
wrote on 30 Jan 2014, 07:39 last edited by
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. -
wrote on 30 Jan 2014, 08:03 last edited by
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(); } -
"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
-
wrote on 30 Jan 2014, 08:36 last edited by
WOW64 because it should be a 32-bit application. I'm using Windows 7 professional 64-bit. Thanks for the link to documentation
-
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
4/7