Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 635639F9A4A for ; Mon, 15 Oct 2007 08:14:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 55837-03 for ; Mon, 15 Oct 2007 08:13:36 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from el-out-1112.google.com (el-out-1112.google.com [209.85.162.182]) by postgresql.org (Postfix) with ESMTP id 90A4A9F9953 for ; Mon, 15 Oct 2007 08:13:36 -0300 (ADT) Received: by el-out-1112.google.com with SMTP id r27so290717ele for ; Mon, 15 Oct 2007 04:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=w+zmJBH6j1V8lXEGVSdwvypQU6DOEc7TLYNHxTtJ2WM=; b=qcUmg4jVd2eL+JBI0O/EyLTxie0ibVL70Fg3hqpt7sa4WnUyGdJ5MYaoR6JyMagIVxJ/hkARRsP77iYFW5wnyfLNhONsPKWlW/Npjrj3Ia3Wkyi6Llhpi+h2jrK/hYbL+vWqUVM8S/SGAKiTeE+paFjO/3NTcZZQ2RVFJrW+VsU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=JOk/HVPtMMwRSi86DYamcdsQ9iXPQC1JI7CEsr0ofrs52nBjmi34QTsJZfiBzNU9DF43bdZN4EDmE7XFmGVOOQYIeCSspg8wN4dbSFbHEYfLbKufgkYZxXdPpx4Dz9ntzvUvuIlKSEbit+MNdoYG/UlpqtvorQiBq9Q4mn3wdKE= Received: by 10.142.178.13 with SMTP id a13mr1374251wff.1192446814346; Mon, 15 Oct 2007 04:13:34 -0700 (PDT) Received: by 10.143.8.5 with HTTP; Mon, 15 Oct 2007 04:13:34 -0700 (PDT) Message-ID: <36e682920710150413s2d9311a3u1d61997af6888998@mail.gmail.com> Date: Mon, 15 Oct 2007 07:13:34 -0400 From: "Jonah H. Harris" To: "Madhu Sudhana Rao" Subject: Re: PostgresSQL server connectiong problem with C-language... Cc: pgsql-interfaces@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/8 X-Sequence-Number: 6635 On 10/15/07, Madhu Sudhana Rao 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/