Hi All,

My application is trying to connect to a PostgreSQL DB which has been created on a linux server (red hat 4)

I am using the 4.3.3 version of Qt that I installed on my Home path.

Follows the essential code I was trying to use to get theconnection to the db.
It is simply a main.cpp:
Qt Code:
  1. #include <QtCore>
  2. #include <QCoreApplication>
  3.  
  4. #include <QtSql>
  5.  
  6. //#include <QSqlDatabase>
  7. //#include <QSqlDriver>
  8. //#include <QSqlQuery>
  9.  
  10. #define DB_DRIVER "QPSQL"
  11. #define DB_HOST "127.0.0.1"
  12. #define DB_DBNAME "myDBname"
  13. #define DB_USER "myDBuser"
  14. #define DB_PASSWD "myDBpwd"
  15.  
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19. QCoreApplication a(argc, argv);
  20.  
  21.  
  22. QSqlDatabase myDB = QSqlDatabase::addDatabase( DB_DRIVER );
  23.  
  24. myDB.setHostName( DB_HOST );
  25. myDB.setDatabaseName( DB_DBNAME );
  26. myDB.setUserName( DB_USER );
  27. myDB.setPassword( DB_PASSWD );
  28.  
  29. myDB.setConnectOptions("connect_timeout=15");
  30.  
  31. bool okDB = myDB.open();
  32.  
  33. if (!okDB) {
  34. printf("Error while trying to open the DB \n");
  35. //qWarning( "Error while trying to open the DB: "+ myDB.lastError().text() );
  36. return FALSE;
  37. }
  38. }
To copy to clipboard, switch view to plain text mode 

When I run the application..I always get the following:

QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers:
Error while trying to open the DB

What should I do ?
Can someone help me?

Thank you very much..

Roberto