odbcisql
无法连接到数据源:
$ isql SMS_GTWY username password -v
返回:
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unknown host machine name.
[ISQL]ERROR: Could not SQLConnect
虽然tsql
可以:
$ tsql -S SERVER001 -U username -P password
返回:
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF8"
1>
$ cat ~/.freetds.conf
:
[SERVER001]
host = 192.168.8.101
port = 1433
tds version = 8.0
client charset = UTF8
$ cat ~/.odbc.ini
:
[SMS_GTWY]
Description = SERVER001 Server
Driver = freetds
Database = SMS_GTWY
ServerName = SERVER001
TDS_Version = 7.1
$ cat ~/.odbcinst.ini
:
[freetds]
Description = MS SQL database access with FreeTDS
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
UsageCount = 1
freetds
并且unixODBC
是在家安装的brew
。
我在 CentOS 上有类似的设置,并且 odbc isql 到 mssqlserver 工作正常。有一个明显的区别,我没有libtdsS.so
在 OS X 上看到安装。
# cat /etc/odbcinst.ini
在 CentOS 上:
[freetds]
Description = MS SQL database access with FreeTDS
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/libtdsS.so
UsageCount = 1
这是问题的原因吗?
ps$ odbcinst -j
返回:
unixODBC 2.3.1
DRIVERS............: /usr/local/Cellar/unixodbc/2.3.1/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/Cellar/unixodbc/2.3.1/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/Cellar/unixodbc/2.3.1/etc/ODBCDataSources
USER DATA SOURCES..: /Users/horace/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
$ odbcinst -q -d
返回:
[freetds]
$ odbcinst -q -s
返回:
[SMS_GTWY]