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:
#include <QtCore>
#include <QCoreApplication>
#include <QtSql>
//#include <QSqlDatabase>
//#include <QSqlDriver>
//#include <QSqlQuery>
#define DB_DRIVER "QPSQL"
#define DB_HOST "127.0.0.1"
#define DB_DBNAME "myDBname"
#define DB_USER "myDBuser"
#define DB_PASSWD "myDBpwd"
int main(int argc, char *argv[])
{
myDB.setHostName( DB_HOST );
myDB.setDatabaseName( DB_DBNAME );
myDB.setUserName( DB_USER );
myDB.setPassword( DB_PASSWD );
myDB.setConnectOptions("connect_timeout=15");
bool okDB = myDB.open();
if (!okDB) {
printf("Error while trying to open the DB \n");
//qWarning( "Error while trying to open the DB: "+ myDB.lastError().text() );
return FALSE;
}
}
#include <QtCore>
#include <QCoreApplication>
#include <QtSql>
//#include <QSqlDatabase>
//#include <QSqlDriver>
//#include <QSqlQuery>
#define DB_DRIVER "QPSQL"
#define DB_HOST "127.0.0.1"
#define DB_DBNAME "myDBname"
#define DB_USER "myDBuser"
#define DB_PASSWD "myDBpwd"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase myDB = QSqlDatabase::addDatabase( DB_DRIVER );
myDB.setHostName( DB_HOST );
myDB.setDatabaseName( DB_DBNAME );
myDB.setUserName( DB_USER );
myDB.setPassword( DB_PASSWD );
myDB.setConnectOptions("connect_timeout=15");
bool okDB = myDB.open();
if (!okDB) {
printf("Error while trying to open the DB \n");
//qWarning( "Error while trying to open the DB: "+ myDB.lastError().text() );
return FALSE;
}
}
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
Bookmarks