473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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
(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;

}
Nov 23 '05 #1
0 2226

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

Similar topics

4
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...
0
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...
2
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...
6
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...
1
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 ...
0
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...
4
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...
1
by: zafarwkhan | last post by:
pls give the procedure to connect from VB.NET to PostgreSQL database
2
by: Wendi Turner | last post by:
ASP.NET 2.0 C# WebService Connect to Database: Sql Server 2005 --------------------------------------------------------------------------------------------------- I have successfully created a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.