ubuntu mac freetds unixodbc

tsql 可以检查freetds链接sqlserver的状况

tsql -S server -U username -P password -D database
(server 定義在 freetds.conf, [] 內的名稱)

1> select * from table
2> go

記得要下 go 才會開始查詢, 離開用 exit 或 quit

也可以用 | 寫成一行批次執行
printf "select * from table\ngo\n" | tsql -S server -U username -P password -D database


isql可以检查unixodbc和freetds的链接情况

isql -v dsn username password


ps:如果链接失败,一定是配置错了,请重复检查拼写是否正确,我在freetds.conf中会把port打成post,在odbc.ini中把Driver打成Dirver,结果检查了2天才发现


附上配置:

/usr/local/freetds/etc/freetds.conf:

[global]

.....

client charset = UTF-8

[xxx]

host = xxx.xxx.com

port = 1433

tds version = 7.0


/usr/local/unixODBC/etc/odbcinst.ini

[FreeTDS]

Description = xxxx

Driver = /usr/local/freetds/lib/libtdsodbc.so

Setup = /usr/local/freetds/lib/libtdsodbc.so


[ODBC]

Trace = Yes

TraceFile = /var/log/httpd/odbcsql.log

ForceTrace = Yes


/usr/local/unixODBC/etc/odbc.ini

[ODBC Data Sources]

TESTdsn = xxx


[TESTdsn]

Description = xxx

Driver = FreeTDS

Trace = No

Servername = xxx

Database = dbname

UID = uid


[Default]

Dirver = /usr/local/freetds/lib/libtdsodbc.so


在mac下默认的odbc是iodbc

用unixODBC的话需要将odbc.ini 和odbcinst.ini 链接至 /Library/ODBC 目录下,若无ODBC目录,请自建

引用:http://www.cocoachina.com/bbs/simple/?t116756.html


你可能感兴趣的:(ubuntu mac freetds unixodbc)