From: | Joel Alpers <joel(at)jkalpers(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Trouble connecting to database using PQconnectdb (C/libpq) |
Date: | 2010-01-16 21:44:35 |
Message-ID: | 4B523343.7040501@jkalpers.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello -
I am working on moving my WEB pages, which include searches in a PostgreSQL
data base, through "libpq".
Old system: Red Hat Linux 9, PostgreSQL 7.4.6
New system: Fedora 11, PostgreSQL 8.4
When I re-compile the program (using updated gnu C++ compilers/libs),
the new version --will-- connect to the data base if I run the CGI program
from the command line, but will --NOT-- connect if I call the CGI program
from a web page.
Here is the C/C++ code:
------------------------------
const char *pcDbArgs = "user=joela dbname=photodb port=5432
host=192.168.111.7";
const char *pcDbName = "photodb";
//
// Connect to PostGresQL data base....
//
printf("\nCalling PQconnectdb(%s)\n", pcDbArgs);
gpPhotoDb = PQconnectdb (pcDbArgs);
if (PQstatus(gpPhotoDb) != CONNECTION_OK)
vExit("Can't connect to database \"%s\" - %s\n", pcDbName,
PQerrorMessage(gpPhotoDb));
printf("Successful connection!\n\n");
(vExit is a simple function that formats an error message)
When run from an HTML page:
Error message:
------------------
Calling PQconnectdb(user=joela dbname=photodb port=5432 host=192.168.111.7)
*** Error - Can't connect to database "photodb" - could not connect to server: Permission denied
Is the server running on host "192.168.111.7" and accepting
TCP/IP connections on port 5432?
I have verified that the postgresql server --is-- running on the server
machine, and --is-- listening on 5432.
I am sure I am leaving something out, so please write if you need more info.
Any thoughts?
Thanks!
Joel.
--
+--------------------------------------------------------------------+
| Joel K. Alpers
| Expressive Black and White Images
| http://www.jkalpers.com
+--------------------------------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-01-16 22:54:16 | Re: Trouble connecting to database using PQconnectdb (C/libpq) |
Previous Message | Greg Stark | 2010-01-16 21:10:53 | Re: Collate order on Mac OS X, text with diacritics in UTF-8 |