472,980 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,980 software developers and data experts.

Embedded SQL - Unable to connect to PostgreSQL Database

Hello Experts,
Trying to run sample Postgrel's ECPG(Embedded
SQL)programs on RHL 9.0.

Im unable to connect to PostgreSQL database (sirishadb) when I run
the program ....
# su postgres (enter)

# /usr/bin/ecpg -t -I/usr/include/pgsql/sample1.pgc (enter)

# gcc -g -o sample1 -I /usr/include/pgsql sample1.c -lecpg -lpq

# ./sample1(enter)

Error Code: -220
Message: No such connection NULL in line 12 ,
Rows : 0
sql error No such connection Null in line 18
I did lot of 'googling' ,searched usenet groups and changed the
following ..............
************************************************** *******************
In the source code (sample1.pcg) ........I tried out various
combinations of connect statements they are

exec sql connect to 'sirishadb@localhost' /* where sirishadb is
databasename */

exec sql connect to 'sirishadb@lucky' /* where sirishadb is
databasename and lucky is hostname of the server */

exec sql connect to tcp:postgresql://localhost:5432/sirishadb as
connect_2 user postgresql using post123
In /var/lib/pgsql/data/postgresql.conf
tcpip_socket = true

In /var/lib/pgsql/data/pg_hba.conf
local all all trust
host all all trust
host all all xxx.xxx.xxx.0 trust

In /etc/rc.d/init.d/postgresql
In this file I added -i to the following statement

su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p
/usr/bin/postmaster -o '-p ${PGPORT} -i' start > /dev/null 2>&1" <

************************************************** *******************
Plz help me in connecting to the database .........Thanx in advance


Source code of sample1.pcg
#include <stdlib.h>
#include <stdio.h>

exec sql include sqlca;

main() {

exec sql connect to 'sirishadb@localhost';

/*exec sql connect to tcp:postgresql://localhost:5432/sirishadb as
connect_2 user postgresql using post123; */
exec sql BEGIN WORK;

exec sql UPDATE XXchildren SET fname = 'Emma' WHERE age = 0;

printf("error code %d, message %s, rows %d, warning %c\n",
sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc, sqlca.sqlerrd[2],

exec sql COMMIT WORK;

exec sql disconnect all;


Nov 23 '05 #1
0 2193

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Ish Ahluwalia | last post by:
Hi: I'm very new to PostGreSql database and actually looking to evaluate for one of our project needs. Below please find some questions. I'm hoping if I can get some insight into these...
by: btober | last post by:
I noticed this gem for allowing the saving of MS-Project 2000 data into a Postgresql database, http://techdocs.postgresql.org/source.php#fmsproject posted by John P Cavanaugh probably a...
by: Jeff Davis | last post by:
I have virtual hosted users on a server and some of them have a postgresql database. I'm concerned about the outside possibility that a user could create an infinite loop and fill up the partition...
by: codepirate | last post by:
Hi All, I am trying to connct to a serverless/embedded PostgreSQL database from a C# application using VS 2005. First of all, is this possible with PostgreSQL? I know this can be done with some...
by: mmr315 | last post by:
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\databaseconnect.php on line 5 i wrote code like this ...
by: David Michael Schruth, | last post by:
Hi, I am sort of in a jam here. I am using the PsycoPG2 library to read data out of a windows XP based PostGIS / PostGreSQL database but I am apparently unable to write (update or insert) even...
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
This is kind of a cross forum problem. I am trying to Connect to database by clicking on: Tools Connect To Database Select: Microsoft SQL Server (SqlClient). However, there are no server listed...
by: zafarwkhan | last post by:
pls give the procedure to connect from VB.NET to PostgreSQL database
by: Wendi Turner | last post by:
ASP.NET 2.0 C# WebService Connect to Database: Sql Server 2005 --------------------------------------------------------------------------------------------------- I have successfully created a...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.