Struggling to connect to the PostgreSQL database
hi everyone, I have struggled for a long time with trying to connect my progam to a PostgreSQL database. At first I tried connecting my program to a mysql database but after a long time of trying to building the mysql driver i gave up and tried a different database (i.e. Postgresql) and still can't connect even with postgresql. code below.
Code:
Server_A
::Server_A(QObject *parent
) :{
// threadPool.setMaxThreadCount(5000);
QString connectionStr
= "Driver={PostgreSQL};Server=127.0.0.1;Port=5432;Database=AsicamtheDB;Uid=root;Pwd=ayaman;";
db.setConnectOptions();
db.setDatabaseName(connectionStr);
if(db.open())
{
qDebug() << "connected to database" <<endl;
}
else
{
qDebug() << "Not connected" <<endl;
qDebug() << db.lastError() <<endl;
qDebug() << db.drivers() <<endl;
}
Re: Struggling to connect to the PostgreSQL database
does anyone know how to resolve this
Re: Struggling to connect to the PostgreSQL database
1. Can you connect with "sqlbrowser" application from Qt examples ?
2. If you are trying to connect to PostgreSQL database, try QPSQL driver:
Re: Struggling to connect to the PostgreSQL database
I did try PQSQL but it also doesn't work.
Re: Struggling to connect to the PostgreSQL database