linux 通过 freetds下访问sqlserver

编译安装freetds

需要root用户,不然make install会报错

$ tar zxvf freetds-stable.tgz(解压)
$ ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib
$ make
$ make install


连接测试

/usr/local/freetds/bin/tsql -H192.168.15.52 -p1433 -Ppassword -Uusername

报错

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20017 (severity 9):
        Unexpected EOF from the server
Error 20002 (severity 9):
        Adaptive Server connection failed
There was a problem connecting to the server

C程序报错

[2013-04-26 21:27:56][ INFO  ] DBSQLServerAccess::GetConnection create connection to of db paysys_db
[2013-04-26 21:27:56][ INFO  ] [DBERROR] severity:9, dberr:20017[Unexpected EOF from the server], oserr:0[Success]
[2013-04-26 21:27:56][ INFO  ] [DBERROR] severity:9, dberr:20002[Adaptive Server connection failed], oserr:0[Success]
[2013-04-26 21:27:56][ INFO  ] [DBERROR] severity:1, dberr:20109[NULL DBPROCESS pointer passed to DB-Library], oserr:0[Success]


打开dump

vi /usr/local/freetds/etc/freetds.conf

dump file = /tmp/freetds.log


vi /tmp/freetds.log

Connecting to ×.×.×.× port 1433 (TDS version 5.0)


在测连接

/usr/local/freetds/bin/tsql -H192.168.15.52 -p1433 -Ppassword -Uusername

查看/tmp/freetds.log

net.c:204:Connecting to 192.168.15.52 port 1433 (TDS version 5.0)

可见$ ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib没生效

vi /usr/local/freetds/etc/freetds.conf   将 tds version 改为7.1

 [global]
          # TDS protocol version
  #   tds version = 8.0
      tds version = 7.1    

再次测试命令和c程序都成功





你可能感兴趣的:(linux 通过 freetds下访问sqlserver)