Re: ECPG could not connect to the database.
От | Artur Pietruk |
---|---|
Тема | Re: ECPG could not connect to the database. |
Дата | |
Msg-id | 20010103012043.E2401@plukwa.net обсуждение исходный текст |
Ответ на | ECPG could not connect to the database. (Joachim Jaeckel <Joachim.Jaeckel@coffeebreak.de>) |
Ответы |
Re: ECPG could not connect to the database.
|
Список | 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@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@plukwa.net --- IBM RS6000/AIX System Administrator, SQL/C++ programmer
В списке pgsql-general по дате отправления: