LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-29-2004, 03:14 PM   #1
vikram_cvk
Member
 
Registered: Jan 2004
Location: Hyderabad , India
Distribution: RHL 9
Posts: 42

Rep: Reputation: 15
Question 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 (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 tcpostgresql://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 tcpostgresql://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;

}
 
Old 05-30-2004, 06:14 AM   #2
vikram_cvk
Member
 
Registered: Jan 2004
Location: Hyderabad , India
Distribution: RHL 9
Posts: 42

Original Poster
Rep: Reputation: 15
Hello somebody plzzz help me out ........with the above problem
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VHCS: ERROR: Unable to connect SQL server ! Travis_NOOB Linux - Software 4 06-27-2009 06:12 PM
Unable to connect to (working) mySQL database rcs1000 Linux - Software 1 10-16-2005 07:23 AM
TOMCAT connect to MS SQL database shane200_ SUSE / openSUSE 1 06-01-2005 01:41 PM
php trying to connect to local sql, error no such database feetyouwell Programming 11 02-08-2005 12:25 PM
Which SQL is suitable for EMbedded SQL on C? hk_michael Programming 4 01-10-2005 05:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration