SQL error: could not connect to database

From: "Juba, Salahaldin I(dot)" <s(dot)juba(at)jacobs-university(dot)de>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: SQL error: could not connect to database
Date: 2010-06-22 18:13:30
Message-ID: D0835FE8F0FF4F4D933AB17A6CF25E390176785F9067@SXCHCL01.jacobs.jacobs-university.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am trying to connect to database using ECPG called 'database' - please see the code below-. When I am excuting the code I am getting this message

Fatal error
SQL error: could not connect to database "database" on line 22
Fatal error
SQL error: connection "NULL" does not exist on line 23

How can I make the ECPG access my database. I have already configured my database to trust all local connections and I can log in to postgresql without password prompt using the psql tool. where did I make a mistake and what are the configuration I need to do

I am using libecpg 6 and postgresql 8.4.4

Best,

#include <iostream>

using namespace std;

EXEC SQL whenever sqlwarning sqlprint;
EXEC SQL whenever sqlerror do GiveUp();

void GiveUp()
{
fprintf(stderr, "Fatal error\n");
sqlprint();
}
int main()
{

EXEC SQL BEGIN DECLARE SECTION;
char id [] = "database";
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO :id;
EXEC SQL CREATE USER tom WITH PASSWORD 'myPassword';
EXEC SQL DISCONNECT ALL;

return 0;
}

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2010-06-22 18:21:01 Re: what happens to postmaster?
Previous Message zach cruise 2010-06-22 18:08:35 what happens to postmaster?