問題描述
我正在嘗試從 Ubuntu 機器訪問托管在我的 Windows 機器上的 MS SQL 服務器.我有一個閃亮的應用程序,可以訪問在 Windows 上運行良好的 MSSQL.我想在 Ubuntu 上使用閃亮的服務器托管它,以便其他人可以訪問網頁并將他們的 SQL 服務器作為應用程序的輸入提供.
所有這些都可以在 Windows 上正常運行.現在我無法讓 unixODBC 工作.我想我的 odbc/freeTDS 安裝和配置是正確的.我可以使用 tsql -S 從 Ubuntu 終端連接和查詢 SQL 數據庫實例.用了一些谷歌搜索,但最終它奏效了.
現在,當我嘗試從 R 連接時,出現此錯誤.
sql <- odbcConnect("abc.xyz.com", "uname", "passwd")
<塊引用>
在odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd"):[RODBC] 錯誤:狀態 08001,代碼 0,消息[unixODBC][FreeTDS][SQL Server]無法連接到數據源 2:在odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd"):[RODBC] 錯誤:狀態 01000,代碼 20002,消息[unixODBC][FreeTDS][SQL Server]Adaptive Server 連接失敗 3:在odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd"):[RODBC] 錯誤:狀態 01000,代碼 20017,消息[unixODBC][FreeTDS][SQL Server]來自服務器的意外 EOF 4:在odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd"): ODBC 連接失敗
freeTDS.conf[abc.xyz.com]主機 = abc.xyz.com端口 = 49475tds 版本 = 8.0odbcinst.ini[免費TDS]說明 = FreeTDS unixODBC 驅動程序驅動程序 =/usr/local/lib/libtdsodbc.so設置 =/usr/local/lib/libtdsodbc.so數據庫配置文件[abc.xyz.com]描述 = 閃亮測試驅動程序 = FreeTDS跟蹤 = 否服務器 = abc.xyz.com\instance_name數據庫 = dbanme端口 = 49475
這個錯誤來自服務器的意外 EOF"對我來說并不陌生.當我嘗試使用 tsql 進行連接時,我遇到了同樣的錯誤.我能夠通過向 freeTDS.conf 添加tds version = 8.0"行來克服這個問題.不確定如何讓 RODBC 使用此配置.我讀過其他用戶可以使用 freeTDS 進行 sql-server 的帖子.不確定這里缺少什么.我也嘗試過重新安裝 RODBC.
我解決了這個問題.odbc.ini 文件中需要 TDS 版本.
TDS_Version = 8.0
tsql 從 freeTDS.conf 讀取版本信息并工作.isql 因同樣的錯誤而失敗,它也在 odbc.ini 中尋找此配置.因此,如果您正在為 R/Python 進行配置,請使用 isql 進行測試.
I'm trying to access MS SQL server hosted on my Windows box from an Ubuntu machine. I have a shiny app that access MSSQL that works fine on Windows. I want to host this with shiny server on Ubuntu so that others can access the webpage and provide their SQL server as input to the app.
All of this works fine on Windows. Now I'm not able to get unixODBC working. I think I've got the odbc/freeTDS installation and configuration correct. I'm able to connect and query SQL DB instance from Ubuntu terminal using tsql -S . It took some googling but eventually it worked.
Now, when I try to connect from R I get this error.
sql <- odbcConnect("abc.xyz.com", "uname", "passwd")
In odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd") : [RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source 2: In odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd") : [RODBC] ERROR: state 01000, code 20002, message [unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed 3: In odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd") : [RODBC] ERROR: state 01000, code 20017, message [unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server 4: In odbcDriverConnect("DSN=abc.xyz.com;UID=uname;PWD=passwd") : ODBC connection failed
freeTDS.conf
[abc.xyz.com]
host = abc.xyz.com
port = 49475
tds version = 8.0
odbcinst.ini
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
odbc.ini
[abc.xyz.com]
Description = Shiny testing
Driver = FreeTDS
Trace = No
Server = abc.xyz.com\instance_name
Database = dbanme
port = 49475
This error "Unexpected EOF from the server" is not new to me. I got the same error when I was trying to connect using tsql. I was able to overcome this by adding "tds version = 8.0" line to freeTDS.conf. Not sure how I can get RODBC to use this config. I've read posts were other users were able to sql-server using freeTDS. Not sure what is missing here. I also tried re-installing RODBC.
I fixed this. TDS version was needed in odbc.ini file.
TDS_Version = 8.0
tsql reads version info from freeTDS.conf and worked. isql was failing with same error and it was also looking for this config in odbc.ini. So test with isql if you are configuring for R/Python.
這篇關于使用 FreeTDS 從 Ubuntu 訪問 RODBC MS SQL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!