PDA

View Full Version : can not use PSQL driver on windows7 machine



mak_user
25th May 2011, 20:33
This is the code for the connection:



bool createPostgreSQLConnection()
{
qDebug() << "--------------------";
qDebug() << "Postgree connection";
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL7");
qDebug() << "DRIVERS :" << QSqlDatabase::drivers();
db.setHostName("127.0.0.1");
db.setDatabaseName("DatabaseName");
db.setPassword("Password");
db.setUserName("UserName");

if (!db.open()) {
qDebug()<< db.lastError().text();
return false;
}
return true;
}


This files I got after compilation of plugin:
libqsqlpsql4.a
libqsqlpsqld4.a
qsqlpsql4.dll
qsqlpsqld4.dll

I copied this files in {QTPath}\plugins\sqldrivers and I still get this error:
--------------------
Postgree connection
QSqlDatabase: QPSQL7 driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
DRIVERS : ("QSQLITE", "QODBC3", "QODBC")
"Driver not loaded Driver not loaded"

I have no idea what could be the problem.

Earlier today I do the same for ODBC driver(compile, copy in the folder and build application) and everything was working fine.
Could you help me?


Note: I use mingw32-make from QT distribution

mak_user
25th May 2011, 23:35
Does anyone work successfully with PostgreSQL under windows7 or should I stop trying?

Lesiok
26th May 2011, 08:30
Did You have installed PostgreSQL on Windows 7 ? If not You must copy to app dir PostgreSQL dll's to.

mak_user
26th May 2011, 12:46
Sure I have installed PostgreSQL. I can work on the tables with pgAdmin III.
What dll's are you talking about?

Added after 4 minutes:

Last thing I did is followed this instruction to build plugins http://www.qtcentre.org/wiki/index.php?title=Building_the_QPSQL_plugin_on_Windo ws_using_MinGW. I build plugins successufully again and QPSQL driver is still not loaded.

..\..\..\sql\drivers\psql\qsql_psql.cpp: In member function 'virtual QSqlIndex QPSQLDriver::primaryIndex(const QString&) const':
..\..\..\sql\drivers\psql\qsql_psql.cpp:979: warning: enumeration value 'VersionUnknown' not handled in switch
..\..\..\sql\drivers\psql\qsql_psql.cpp: In member function 'virtual QSqlRecord QPSQLDriver::record(const QString&) const':
..\..\..\sql\drivers\psql\qsql_psql.cpp:1056: warning: enumeration value 'VersionUnknown' not handled in switch

This are the warnings I got while compileing plugins. I have no idea how to proceed. Maybe you can help me.

Lesiok
26th May 2011, 15:28
DLL's from POSTGRESQL_DIR\bin. Plugin use them to connect to server.
PostgreSQL plugin IS working on Windows 7.
We are working with MS Visual C++.