Re: PostgresSQL server connectiong problem with C-language...

Поиск
Список
Период
Сортировка
От Jonah H. Harris
Тема Re: PostgresSQL server connectiong problem with C-language...
Дата
Msg-id 36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com
обсуждение исходный текст
Ответ на PostgresSQL server connectiong problem with C-language...  ("Madhu Sudhana Rao" <madhu542@gmail.com>)
Список pgsql-interfaces
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/


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "Madhu Sudhana Rao"
Дата:
Сообщение: PostgresSQL server connectiong problem with C-language...
Следующее
От: Adam Radlowski
Дата:
Сообщение: sending data with COPY SQL command, libpq and structure of SELECT resulting buffer