Thread: new to Unixodbc: can't connect to Postgresql

new to Unixodbc: can't connect to Postgresql

From
lchan@mail.arc.nasa.gov (mlc)
Date:
Hi,
I'm new to postgresql Unix odbc (iodbc).  I am trying to test my
unixodbc connection to a local Postgres DB via the provided
"iodbctest" program and have been unsuccessful in getting a "SQL>"
prompt.  Instead, it prints out a "Have nice day" message.   Been
working on this problem for a week now and have not come up with
anything close at all.
Searched the web and this forum for any "ideas" as to what is wrong
and can't find anything.  Any input or help in pointing me to the
right direction is highly appreciated and invaluable.

Thank you in advance for any help on this!

Pasted below is what is currently downloaded and running:
1) Postgres 7.4.3 installed and have created several databases.
2) Downloaded IODBC Driver Manager: 03.51.0002.0224
3) $ODBCINI = /u7/uav/pgsql_odbc/.odbc.ini ;
LD__LIBRARY_PATH=/u7/uav/pgsql/lib:/u7/uav/libiodbc/lib/:/u7/uav/pgsql_odbc/lib:....
4) .odbc.ini file content below

[ODBC Data Sources]
postsql1=PostgreSQL ODBC Drive


[postsql1]
Driver=/u7/uav/pgsql_odbc/lib/psqlodbc.so
Host=localhost
ServerType=Postgres
Database=testdb
Username=dbadm
ReadOnly=no
FetchBufferSize = 60
Port=5432


[ODBC]
Trace=1
TraceFile=/u7/uav/odbc.trace
Debug=1
DebugFile=/u7/uav/odbc.log
------------------------------------

5) odbcinist.ini file content

[PostgresSQL1]
Description=ODBC for PostgreSQL
Driver=/u7/uav/pgsql_odbc/lib/psqlodbc.so

[PostgresSQL]
Description=ODBC for PostgreSQL
Driver=/u7/uav/pgsql_odbc/lib/psqlodbc.so
FileUsage = 1

[ODBC]
Trace = 1
Pooling = No
FileUsage =1
CommLog =1
Debug = 1


6) output :
aloe 92% ./iodbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.51.0002.0224

Enter ODBC connect string (? shows list): ?

DSN | Description
---------------------------------------------------------------
postsql | PostgreSQL
postsql1 | PostgreSQL ODBC Drive

Enter ODBC connect string (? shows list)SN= postsql

Have a nice day.aloe 93%

Re: new to Unixodbc: can't connect to Postgresql

From
Richard Huxton
Date:
mlc wrote:
> Hi,
> I'm new to postgresql Unix odbc (iodbc).  I am trying to test my
> unixodbc connection to a local Postgres DB via the provided
> "iodbctest" program and have been unsuccessful in getting a "SQL>"
> prompt.  Instead, it prints out a "Have nice day" message.   Been
> working on this problem for a week now and have not come up with
> anything close at all.
> Searched the web and this forum for any "ideas" as to what is wrong
> and can't find anything.  Any input or help in pointing me to the
> right direction is highly appreciated and invaluable.

1. Make sure you are logging connection attempts in postgresql.conf and
see if anything is happening there.
2. Make sure PG is listening on port 5432 (telnet localhost 5432, hit
return twice and you should see an error message)
3. Check your pg_hba.conf is allowing access from localhost (NOT local)
via passwords.

--
   Richard Huxton
   Archonet Ltd

Re: new to Unixodbc: can't connect to Postgresql

From
Richard Huxton
Date:
lchan wrote:
> Hi Richard,
> Thank you for responding to my plea for help.

No problem - please try to keep the mailing list cc'ed - there are
smarter people than me on it.

>> 1. Make sure you are logging connection attempts in postgresql.conf
>> and see if anything is happening there.
>
> I have double checked the postgresql.conf  file.  There's only a trace
> file produced, and it's a SQLERROR -2 (SQL_INVALID_HANDLE).

This is the odbc logs - we also want to look at the postgresql logs.
Their location is usually defined in your postgresql startup script.

 > Pasted
> below is my postgres.conf file.  I would be very grateful if you let me
> know, if
> you spot anything that's incorrect.

Where is postgresql logging to? Find out, then add the following lines
to your postgresql.conf:

log_connections=true
log_statement=true

Restart postgresql and this will then log every connection and every SQL
  statement you send.

Connect using "psql -h localhost -U myuser mydatabase", you should be
asked for your password and get a prompt. Check the logs to make sure
the successful connection is logged.

Then try to connect via odbc and see what the postgresql logs say.

--
   Richard Huxton
   Archonet Ltd