FreeTDS无法从odbc.ini读取Servername

时间:2015-12-05 16:40:20

标签: sql-server ubuntu odbc freetds

我正在尝试将FreeTDS设置为连接到Ubuntu 14.04和FreeTDS 4.2中的mssql服务器

然而,由于不明原因,osql无法读取 Servername 设置。 如果我使用isql,它的工作原理。但是我的程序使用odbc.ini设置。

我做错了什么?

我的odbc.ini;

[ODBC Data Sources]
Test = My Test Server

[mssql]
Description = My Test Server
Driver      = FreeTDS
Trace       = No
TDS_Version = 4.2
Servername  = mssql

命令

~$ osql -S mssql -U user -P password 
checking shared odbc libraries linked to isql for default directories...
strings: '': No hay tal fichero
    trying /tmp/sql ... no
    trying /tmp/sql ... no
    trying /etc ... OK
checking odbc.ini files
    reading /home/business/.odbc.ini
[mssql] not found in /home/business/.odbc.ini
    reading /etc/odbc.ini
[mssql] found in /etc/odbc.ini
found this section:
    [mssql]
    Description = My Test Server
    Driver      = FreeTDS
    Trace       = No
    TDS_Version = 4.2
    Servername  = mssql

looking for driver for DSN [mssql] in /etc/odbc.ini
  found driver line: "  Driver      = FreeTDS"
  driver "FreeTDS" found for [mssql] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /etc/odbcinst.ini
  found driver line: "  Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so"
  found driver /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so for [FreeTDS] in odbcinst.ini
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [mssql] has servername "" (from /etc/odbc.ini)

1 个答案:

答案 0 :(得分:2)

你想在这里解决一些问题。首先,在odbc.ini中,它是“服务器”而不是“服务器”。这是一个例子。

ODBC.INI:

[myserver]
Driver = FreeTDS
Server = myserver.mydomain.com
Port = 1433
TDS_Version = 7.2

freetds.conf:

[myserver]
host = myserver.mydomain.com
port = 1433
tds version = 7.2

此外,您还想要使用更高的TDS版本。 TDS 4.2适用于Microsoft SQL Server 6.0!尽管有文档,我发现可以与所有产品一起使用。要选择合适的TDS版本,请参见此处:

http://www.freetds.org/userguide/choosingtdsprotocol.htm

您最有可能想要版本7.2或7.3。祝你好运!