Thread: Problem with unixODBC and PostgreSQL

Problem with unixODBC and PostgreSQL

From
Julie Reier
Date:
Hi. I am hoping that someone can advise me on an issue I am having with connecting to a postgresql DB via unixODBC.

I am using an ubuntu VM to test the configuration. Here’s what I did:
  1. Installed unixODBC
  2. Installed odbc-postgresql
  3. Configured odbc drivers and data sources.
I am able to connect to the database via the psql command. However, osql is failing. Here’s the output:

rnduser@rnduser-VirtualBox:~$ osql -S rndredshift6 -U readonly -P *******
checking shared odbc libraries linked to isql for default directories...
strings: '': No such filetrying /tmp/sql ... notrying /tmp/sql ... notrying /etc ... OK
checking odbc.ini filesreading /home/rnduser/.odbc.ini
[rndredshift6] found in /home/rnduser/.odbc.ini
found this section:[rndredshift6]Driver		= PostgreSQLDescription		= data source for rndredshiftServer		= 10.191.4.97Port		= 5439Database		= prod
looking for driver for DSN [rndredshift6] in /home/rnduser/.odbc.ini found driver line: "	Driver		= PostgreSQL" driver "PostgreSQL" found for [rndredshift6] in .odbc.ini
found driver named "PostgreSQL"
"PostgreSQL" is not an executable file
looking for entry named [PostgreSQL] in /etc/odbcinst.ini found driver line: "	Driver		= /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so" found driver /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so for [PostgreSQL] in odbcinst.ini
/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so is an executable file
"Server" found, not using freetds.conf
Server is "10.191.4.97"
looking up hostname for ip address 10.191.4.97
osql: warning: no DNS hostname found for "10.191.4.97"
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]           [-R number] [-m flag] hostname [server]      -a is equivalent to -v -t ANY      -c specifies query class for non-IN data      -C compares SOA records on authoritative nameservers      -d is equivalent to -v      -l lists all hosts in a domain, using AXFR      -i IP6.INT reverse lookups      -N changes the number of dots allowed before root lookup is done      -r disables recursive processing      -R specifies number of retries for UDP packets      -s a SERVFAIL response should stop query      -t specifies the query type      -T enables TCP/IP mode      -v enables verbose output      -w specifies to wait forever for a reply      -W specifies how long to wait for a reply      -4 use IPv4 query transport only      -6 use IPv6 query transport only      -m set memory debugging flag (trace|record|usage)
osql: no IP address found for ""
rnduser@rnduser-VirtualBox:~$ 
Telnet to 10.191.4.97 on port 5439 works.
Any ideas of what’s going on here?
Thanks,
Julie
This email is intended only for the use of the individual(s) to whom it is addressed. If you have received this communication in error, please immediately notify the sender and delete the original email.

Re: Problem with unixODBC and PostgreSQL

From
Adrian Klaver
Date:
On 01/22/2015 08:35 AM, Julie Reier wrote:
> Hi. I am hoping that someone can advise me on an issue I am having with
> connecting to a postgresql DB via unixODBC.
>
> I am using an ubuntu VM to test the configuration. Here’s what I did:
>
>  1. Installed unixODBC
>  2. Installed odbc-postgresql
>  3. Configured odbc drivers and data sources.
>
> I am able to connect to the database via the psql command. However, osql
> is failing. Here’s the output:
>
> rnduser@rnduser-VirtualBox:~$ osql -S rndredshift6 -U readonly -P *******
>
> checking shared odbc libraries linked to isql for default directories...
> strings: '': No such file
>     trying /tmp/sql ... no
>     trying /tmp/sql ... no
>     trying /etc ... OK
> checking odbc.ini files
>     reading /home/rnduser/.odbc.ini
> [rndredshift6] found in /home/rnduser/.odbc.ini
> found this section:
>     [rndredshift6]
>     Driver        = PostgreSQL
>     Description        = data source for rndredshift
>     Server        = 10.191.4.97
>     Port        = 5439
>     Database        = prod
>
> looking for driver for DSN [rndredshift6] in /home/rnduser/.odbc.ini
>    found driver line: "    Driver        = PostgreSQL"
>    driver "PostgreSQL" found for [rndredshift6] in .odbc.ini
> found driver named "PostgreSQL"
> "PostgreSQL" is not an executable file
> looking for entry named [PostgreSQL] in /etc/odbcinst.ini
>    found driver line: "    Driver        = /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so"
>    found driver /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so for [PostgreSQL] in odbcinst.ini
> /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so is an executable file
> "Server" found, not using freetds.conf
> Server is "10.191.4.97"
> looking up hostname for ip address 10.191.4.97
> osql: warning: no DNS hostname found for "10.191.4.97"
> Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
>              [-R number] [-m flag] hostname [server]
>         -a is equivalent to -v -t ANY
>         -c specifies query class for non-IN data
>         -C compares SOA records on authoritative nameservers
>         -d is equivalent to -v
>         -l lists all hosts in a domain, using AXFR
>         -i IP6.INT reverse lookups
>         -N changes the number of dots allowed before root lookup is done
>         -r disables recursive processing
>         -R specifies number of retries for UDP packets
>         -s a SERVFAIL response should stop query
>         -t specifies the query type
>         -T enables TCP/IP mode
>         -v enables verbose output
>         -w specifies to wait forever for a reply
>         -W specifies how long to wait for a reply
>         -4 use IPv4 query transport only
>         -6 use IPv6 query transport only
>         -m set memory debugging flag (trace|record|usage)
> osql: no IP address found for ""
> rnduser@rnduser-VirtualBox:~$
>
> Telnet to 10.191.4.97 on port 5439 works.
>
> Any ideas of what’s going on here?

looking up hostname for ip address 10.191.4.97
osql: warning: no DNS hostname found for "10.191.4.97"

Looks like osql is trying to do a reverse DNS lookup and fails to find a
hostname. Not sure why that is a problem, but this looks to be a FreeTDS
issue. You will probably find the answer faster here:

http://lists.ibiblio.org/mailman/listinfo/freetds

>
> Thanks,
>
> Julie
>
> *This email is intended only for the use of the individual(s) to whom it
> is addressed. If you have received this communication in error, please
> immediately notify the sender and delete the original email.*


--
Adrian Klaver
adrian.klaver@aklaver.com