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

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Wed Jul 16 03:26:40 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:
> 

You can use even 0.82, but this is not the problem...

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

strange port, are you sure is not 1433 ?? 1434 is default udp port for instance
informations.

> 
> ...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

Mmmm... why same file for 2 drivers ??

> ===========
> 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
> 

this could work if db01 is the dns name, probably you want Servername, not Server.

> [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

This should work, I don't know trace (which are unixODBC fields)

> =========
> 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
> 

well, driver is correct (error came from FreeTDS).

> 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.
> 

You could try a

strace -e connect isql db01-2 $USER $PASS

freddy77
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3129 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20080716/9aa8d6b0/attachment.bin 


More information about the FreeTDS mailing list