QPSQL and failed connection
I am trying to open a database through Qt . Here is the code.
Code:
inline bool createConnection()
{
db.setHostName("localhost");
db.setDatabaseName("/home/pgdata/data1");
db.setUserName("pgdata");
db.setPassword("krajesh");
if (!db.open()) {
db.lastError().text());
return false;
}
return true;
}
it results in the error. FATAL: coulfd't coonnect to database /home/pgdata/data1.
/home/pgdata/data1 do exists. It is a cluster of database inside it i had created one with default name pgdata. but opening it also results in same name. I can acess and query over it using psql from command prompt. Also same code with QMYSQL works well.
quickNitin
Re: QPSQL and failed connection
The database name is what you specify in USE commands at the SQL prompt. What do you USE when you operate from the prompt?
Re: QPSQL and failed connection
i have used same at both places. Only difference here is i am specifying complete path.
This i have created using createdb command.
Exact error is:
Code:
FATAL: /home/pgdata/data1 doesn't exist
QPSQL :unable to connect
I am completely out of ideas what is the issue. Is there something i missed while installing Qt? This code which i am trying to compile is sample code from Qt book so i suppose it it bug free.
Anyone can list out all the possibilities causing issues?
quickNitin
Re: QPSQL and failed connection
But you can't specify a complete path! Maybe the code you are referring to concerns an sqlite database?
Re: QPSQL and failed connection
Quote:
Originally Posted by
quickNitin
I can acess and query over it using psql from command prompt.
How do you start psql? Do you specify database name? What does \l command print?
Most likely your database is named "pgdata".