Embedded SQL - Unable to connect to PostgreSQL Database
От | cvk_ind@rediffmail.com (vicky) |
---|---|
Тема | Embedded SQL - Unable to connect to PostgreSQL Database |
Дата | |
Msg-id | fd3fe14a.0405291226.5902a0a0@posting.google.com обсуждение исходный текст |
Список | pgsql-hackers |
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 (enter) # ./sample1(enter) Error Code: -220 Message: No such connection NULL in line 12 , Rows : 0 Warning: 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 127.0.0.1 255.255.255.255 trust host all all xxx.xxx.xxx.0 255.255.255.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" < /dev/null ********************************************************************* Plz help me in connecting to the database .........Thanx in advance Regards, Vikram 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], sqlca.sqlwarn[0]); exec sql COMMIT WORK; exec sql disconnect all; return EXIT_SUCCESS; }
В списке pgsql-hackers по дате отправления: