Re: Cannot login, with C/C++ program

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel <danwgrace(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Cannot login, with C/C++ program
Date: 2009-12-02 21:42:01
Message-ID: 22806.1259790121@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Daniel <danwgrace(at)gmail(dot)com> writes:
> I have written a C/C++ program that trys to log into a local
> PostgreSQL database. Here is the code:

> pg_conn = PQconnectdb(
> "hostaddr = '127.0.0.1' port = '' dbname = 'TBDB' user = 'sysdba'
> password = 'stelmo777' connect_timeout = '10'");
> if (!pg_conn)
> {
> return false;
> }
> if (PQstatus(pg_conn) != CONNECTION_OK)
> {
> return false; // <- execution reaches here.

> I checked the database, user and password by logging in with psql.
> What could be wrong?

If you print out the connection object's error message, you might
find out. It's hard to guess about it without that information.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pedro Doria Meunier 2009-12-02 22:30:21 Re: Cannot login, with C/C++ program
Previous Message Tom Lane 2009-12-02 21:40:05 Re: Catastrophic changes to PostgreSQL 8.4