Search code examples
linuxubuntufreetdsunixodbc

How configure freetds and unixodbc on Linux Ubuntu


I'm trying to create a connection with freetds + unixodbc on Linux to Database on Windows, I configured /etc/freetds/freetds.conf, /etc/odbc.ini and /etc/odbcinst.ini:

freetds.conf:

 A typical Microsoft server
 [wsus]
  host = my-ip-sql-server
  port = 1433
  tds version = 4.2

odbc.ini

[wsus]
  Driver = FreeTDS
  Trace = No
  ServerName = wsus
  Database= Asegurador

as

odbcinst.ini

[wsus]
  Description = tdsodbc
  Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
  FileUsage = 1
  CPTimeout = 5

Command output = tsql -C :

Compile-time settings (established with the "configure" script)
                            Version: freetds v0.91
             freetds.conf directory: /etc/freetds
     MS db-lib source compatibility: no
        Sybase binary compatibility: yes
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 4.2
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: yes

When I run a tsql the connection is succesfull:

$ tsql -S  wsus -U username -P password
locale is "es_ES.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> select top 1 FechaFactura, Vendedor, ClaseDoc  from [Aseguradoras].[dbo].[mknDetalleAseguradoras]
2> go
FechaFactura    Vendedor    ClaseDoc
2014-07-12         xx           2

But when I run a isql:

$ isql -v wsus username Password [IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified [ISQL]ERROR: Could not SQLConnect

Thanks in advance.


Solution

  • In odbcinst.ini, you need to provide the driver name, not the DSN. Change:

    [wsus]
    

    to:

    [FreeTDS]
    

    You should also modify the TDS version, most likely to 7.3 (SQL Server 2008 - 2014), as mentioned above.

    That should do this trick! Good luck.