Re: ECPG could not connect to the database.

From: Artur Pietruk <arturp(at)plukwa(dot)pdi(dot)net>
To: Joachim Jaeckel <Joachim(dot)Jaeckel(at)coffeebreak(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ECPG could not connect to the database.
Date: 2001-01-03 00:20:43
Message-ID: 20010103012043.E2401@plukwa.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Dec 04, 2000 at 10:11:00AM +0100, Joachim Jaeckel wrote:
> Hello,
>
> I´m trying to use embedded sql with postgresql through ecpg. But if I
> try to make a connection to my database, I get the following error at
> runtime:
>
> Could not connect to database buecher(at)localhost in line 18.
> (I´m using postgresql 7.0.2)
>
> psql and the jdbc is working, but not the ecpg connection.
>
> I tried the follwing connect statements:
>
> exec sql connect to buecher;
> exec sql connect to buecher user joe;
> exec sql connect to buecher user joe identified by blubber;
>
> and everything ends in the same message.
>
> Do I have to configure something additionally for ecpg? Or anything else
> special?
>
> Hope you could help me?

I'm sorry that I am answering that question after a month, but i
did not see someone solving your problem.

First of all - you have done everything right with your code. You
simply rediscovered a long standing ECPG BUG, which was introduced years
ago in PostgreSQL 6.4 (or was it 6.3?). This bug was reported here by me
and other people, we had found where is the problem and how to work around
this ;) (Hi developers... I hope that you are reading this... Maybe it's
about the time to fix it...? :))).

So, here is the work-around and explanation of the bug:

ECPG is generating wrong code. Try to generate *.c file by ecpg,
and look at the generated "ECPGconnect". In my case that line looks like this:

--8<--
{ ECPGconnect(__LINE__, NULL, "biblioteka" , NULL ,NULL, 0);}
--8<--

But that is wrong, it should look like this:

--8<--
{ ECPGconnect(__LINE__, "biblioteka" , NULL , NULL ,NULL, 0);}
--8<--

So, the workaround is to change the second argument of ECPGconnect
for the third argument, inside code generated by ecpg.

If you do not want to do it every time you will change your source
code and have to recompile it, write:

ECPGconnect(__LINE__, "buecher" , NULL , NULL ,NULL, 0);

instead of

exec sql connect to buecher;

inside your source code.

Best regards,

--- Artur Pietruk, arturp(at)plukwa(dot)net
--- IBM RS6000/AIX System Administrator, SQL/C++ programmer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric Mueller 2001-01-03 00:20:53 RE: RE: Re: MySQL and PostgreSQL speed compare
Previous Message Michael Dunn 2001-01-03 00:17:51 Testing for null value in arrays