[freetds] tsql works, unixODBC's isql doesn't

Joel Fouse joel at fouse.net
Tue Jul 15 17:40:59 EDT 2008


I've been spending way too much time trying to get this working, and
have tried every one of various permutations I can think of or come
across in various mailing lists and forums and documentation.  Everyone
else seems to end with "Got it working, thanks!"  But I haven't,
yet.  :P

Environment: RHEL 4.1, unixODBC-2.2.11-1.RHEL4.1 was already installed.
I installed the unixODBC-devel-2.2.11-1 rpm to get the header files, and
compiled freeTDS 0.83 as such:

[root at web ~]# tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.83.dev.20080714
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 5.0
                              iODBC: no
                           unixodbc: yes

freetds.conf contains the following:

freetds.conf
========
[db01]
        host = 192.168.1.101
        port = 1434
        tds version = 7.0


...And tsql connects nicely, whether using -H/-p w/ IP and port, or -S
w/ db01.

All well and good, on to unixODBC.  Here's the relevant files:

odbcinst.ini
=======
[FreeTDS]
Description             = TDS driver with Protocol v7.0
Driver          = /usr/local/lib/libtdsodbc.so

[FreeTDS2]
Description             = v0.63 with protocol v8.0
Driver          = /usr/local/lib/libtdsodbc.so
Setup           = /usr/lib/libtdsS.so.1
UsageCount              = 1
===========
END odbcinst.ini


odbc.ini
=====
[ODBC Data Sources]
db01 = This is db01
db01-2 = This is db01-2

[Default]
Driver          = /usr/local/lib/libtdsodbc.so

[db01]
Description             = This is db01
Driver          = /usr/local/lib/libtdsodbc.so
# Driver                = FreeTDS
# Server                = 192.168.1.101
Server          = db01
# Port          = 1434
# tds_version           = 7.0
Trace           = Yes
Tracefile               = /tmp/odbc.log

[db01-2]
Description             = This is db01-2
Driver          = /usr/local/lib/libtdsodbc.so
# Driver                = FreeTDS2
Server          = 192.168.1.101
Port            = 1434
TDS_Version             = 7.0
Trace           = Yes
Tracefile               = /tmp/odbc.log
ForceTrace      = Yes
=========
END odbc.ini


As you can probably see from the comments, I've tried several variations
of Driver and Server.  But pretty much no matter what I do (except
misspell the DSN; that's a different error, obviously), I see this:

[root at web ~]# isql -v db01-2 $USER $PASS
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect

And there's no tracefile or logfile that I can find.  TDSDUMPCONFIG
doesn't do squat (it does when tsql connects successfully), and the
tracefile specified in odbc.ini never gets created.

I take that back -- even if I give isql a bogus DSN it still spits out
the same thing.  I don't think it did at some point in my testing, but
there it is.  Somewhere I found a reference to using the osql util, but
that seems to be looking for iODBC stuff rather than unixODBC:

[root at web apps]# ./osql -S db01 -U $USER -P $PASS
osql: error: no potential directory strings in "/usr/bin/isql"
isql strings are:
+ /lib/ld-linux.so.2
+ /lib/ld-linux.so.2

Again, TDSDUMPCONFIG does nothing here.

Any help?  Pointers, logging tips, 2x4 upside the head?  I'll take
anything.

- joel




More information about the FreeTDS mailing list