我正在尝试使用Linux建立与SQL Server实例的连接。 我的FreeTDS设置似乎可以正常工作,但我的unixODBC设置却无效。
当我使用tsql访问数据库时,将发生以下情况:
tsql -S STCONNSQLDEV\
scSwitchboard -U sa_RSCSWITCHBOARD -P password
locale is"en_US.UTF-8"
locale charset is"UTF-8"
using default charset"UTF-8"
这是我使用isql时发生的情况:
isql RscSwitchboard sa_RSCSWITCHBOARD password -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[37000][unixODBC][FreeTDS][SQL Server]Login failed for user 'sa_RSCSWITCHBOARD'.
[ISQL]ERROR: Could not SQLConnect
我的/etc/freetds/freetds.conf:
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage"man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
; tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[egServer70]
host = ntmachine.domain.com
port = 1433
tds version = 7.0
[STCONNSQLDEV\
scSwitchboard]
host = 192.168.15.12
port = 1433
tds version = 8.0
client charset = UTF-8
我的/etc/odbc.ini:
[RscSwitchboard]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = Yes
TraceFile = /tmp/rscswitchboard
servername = STCONNSQLDEV\
scSwitchboard
Database = RscSwitchboard
Port = 1433
我的/etc/odbcinst.ini:
[FreeTDS]
Description = tdsodbc
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
[ODBC]
DEBUG=1
Trace = Yes
TraceFile = /tmp/rscswitchboard
我的跟踪文件:
[ODBC][5002][1406656337.564089][__handles.c][450]
Exit:[SQL_SUCCESS]
Environment = 0x14b4750
[ODBC][5002][1406656337.564197][SQLAllocHandle.c][364]
Entry:
Handle Type = 2
Input Handle = 0x14b4750
[ODBC][5002][1406656337.564254][SQLAllocHandle.c][482]
Exit:[SQL_SUCCESS]
Output Handle = 0x14b5080
[ODBC][5002][1406656337.564321][SQLConnect.c][3615]
Entry:
Connection = 0x14b5080
Server Name = [RscSwitchboard][length = 14 (SQL_NTS)]
User Name = [sa_RSCSWITCHBOARD][length = 17 (SQL_NTS)]
Authentication = [********][length = 8 (SQL_NTS)]
UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'
DIAG [42000] [FreeTDS][SQL Server]Login failed for user 'sa_RSCSWITCHBOARD'.
DIAG [S1000] [FreeTDS][SQL Server]Unable to connect to data source
[ODBC][5002][1406656337.828774][SQLConnect.c][3983]
Exit:[SQL_ERROR]
[ODBC][5002][1406656337.828841][SQLError.c][430]
Entry:
Connection = 0x14b5080
SQLState = 0x7fff8cbb4b10
Native = 0x7fff8cbb4b0c
Message Text = 0x7fff8cbb4b20
Buffer Length = 500
Text Len Ptr = 0x7fff8cbb4b0a
[ODBC][5002][1406656337.828912][SQLError.c][467]
Exit:[SQL_SUCCESS]
SQLState = S1000
Native = 0x7fff8cbb4b0c -> 0
Message Text = [[unixODBC][FreeTDS][SQL Server]Unable to connect to data source]
[ODBC][5002][1406656337.829032][SQLError.c][430]
Entry:
Connection = 0x14b5080
SQLState = 0x7fff8cbb4b10
Native = 0x7fff8cbb4b0c
Message Text = 0x7fff8cbb4b20
Buffer Length = 500
Text Len Ptr = 0x7fff8cbb4b0a
[ODBC][5002][1406656337.829098][SQLError.c][467]
Exit:[SQL_SUCCESS]
SQLState = 37000
Native = 0x7fff8cbb4b0c -> 18456
Message Text = [[unixODBC][FreeTDS][SQL Server]Login failed for user 'sa_RSCSWITCHBOARD'.]
[ODBC][5002][1406656337.829179][SQLError.c][430]
Entry:
Connection = 0x14b5080
SQLState = 0x7fff8cbb4b10
Native = 0x7fff8cbb4b0c
Message Text = 0x7fff8cbb4b20
Buffer Length = 500
Text Len Ptr = 0x7fff8cbb4b0a
[ODBC][5002][1406656337.829234][SQLError.c][467]
Exit:[SQL_NO_DATA]
[ODBC][5002][1406656337.829284][SQLError.c][510]
Entry:
Environment = 0x14b4750
SQLState = 0x7fff8cbb4b10
Native = 0x7fff8cbb4b0c
Message Text = 0x7fff8cbb4b20
Buffer Length = 500
Text Len Ptr = 0x7fff8cbb4b0a
[ODBC][5002][1406656337.829332][SQLError.c][547]
Exit:[SQL_NO_DATA]
[ODBC][5002][1406656337.829423][SQLFreeHandle.c][279]
Entry:
Handle Type = 2
Input Handle = 0x14b5080
[ODBC][5002][1406656337.829477][SQLFreeHandle.c][330]
Exit:[SQL_SUCCESS]
[ODBC][5002][1406656337.829540][SQLFreeHandle.c][212]
Entry:
Handle Type = 1
Input Handle = 0x14b4750
我正在使用Ubuntu 14.04 x86_64。 有没有人有什么建议?
Andreis解决方案有效吗?
我会尝试以下方法:
== freetds.conf
[global]
charset = UTF-8
client charset = UTF-8
timeout = 10
connect timeout = 10
[server_a]
host = 192.168.15.12
port = 1433
== /etc/odbc.ini
[config_a]
Driver = FreeTDS
Servername = server_a
Database = RscSwitchboard
Port = 1433
$ isql -v config_a sa_RSCSWITCHBOARD密码
如果仍不能解决问题,请尝试
tds version = 7.3