pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonah H. Harris <jonah.harris@gmail.com>
To: Madhu Sudhana Rao <madhu542@gmail.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PostgresSQL server connectiong problem with C-language...
Date: Mon, 15 Oct 2007 07:13:34 -0400
Message-ID: <36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com> (raw)
In-Reply-To: <da0ce8670710142313i10b0cf40w616032232498a86d@mail.gmail.com>
References: <da0ce8670710142313i10b0cf40w616032232498a86d@mail.gmail.com>

On 10/15/07, Madhu Sudhana Rao <madhu542@gmail.com> wrote:
> I wrote a C-program for connecting to postgresSQL server and get the
> data from the database.
> ...
> Connection to database failed.
> could not connect to server: No such file or directory
> Is the server running locally and accepting
> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Is the server running?  Does the log show anything unusual?  Did you
change any of the unix_socket_* configuration parameters?  Do you have
a database named test (although that would give a different error
message).  Can you connect with psql?

As far as libpq is concerned, the best thing to do is start with is
the libpq example code and work from there.

Also, sorry to be picky about your code, but your conditional is:

if (PQstatus(conn) == CONNECTION_BAD)

It's generally better to make the conditional check for an alteration
to the expected result:

if (PQstatus(conn) != CONNECTION_OK)

It just makes it easier to understand what should've happened.

-- 
Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324
EnterpriseDB Corporation                | fax: 732.331.1301
499 Thornall Street, 2nd Floor          | jonah.harris@enterprisedb.com
Edison, NJ 08837                        | http://www.enterprisedb.com/



view thread (2+ messages)

Message-ID: <36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com>
Permalink:  ../36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com/
Also on:    postgresql.org/message-id/36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jonah.harris@gmail.com, madhu542@gmail.com
  Subject: Re: PostgresSQL server connectiong problem with C-language...
  In-Reply-To: <36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox