1

I am having ODBC problems on Ubuntu (12.10). The weirdest part about it - I set all of this up a year ago and haven't had any trouble with it until recently.

I am trying to connect to a MS SQL Server using FreeTDS / ODBC. I primarily use sqsh to talk to the server, but when I need to do anything analytical, I pull the data into R using RODBC. Yesterday, when I tried to do this, it failed.

I can connect to the database using sqsh / tsql. This makes me think FreeTDS is still set up correctly. The problem seems to be on the ODBC side. So, I pulled out osql and I get the strangest error.

checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
        trying /tmp/sql ... no
        trying /tmp/sql ... no
        trying /etc ... OK
checking odbc.ini files
        reading /home/andy/.odbc.ini
[CANS] found in /home/andy/.odbc.ini
found this section:
        [CANS]
        Description                     = FreeTDS
        Driver                      = FreeTDS
        Servername                      = Portland
        Database                        = CANS
        UID                             = NotRelevant
        PWD                             = NotRelevant
        Port                        = 1433

looking for driver for DSN [CANS] in /home/andy/.odbc.ini
  found driver line: "  Driver                      = FreeTDS"
  driver "FreeTDS" found for [CANS] in .odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /etc/odbcinst.ini
  found driver line: "  Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so"
  found driver /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so for [FreeTDS] in 
        odbcinst.ini
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so is an executable file
    Using ODBC-Combined strategy
DSN [CANS] has servername "Portland" (from /home/andy/.odbc.ini)
cannot read "/home/andy/.freetds.conf"
/etc/freetds/freetds.conf is a readable file
looking for [Portland] in /etc/freetds/freetds.conf
found this section:
    [Portland]
        host           = 63.***.**.***
        port           = 1433
        tds version    = 8.0
        client charset = UTF-8
looking up hostname for ip address 63.***.**.***
osql: no IP address found for "host145.actwd.net"

I don't understand why osql is trying to resolve an IP address when it has it already. This server has quite a bit of IP blocking going on to help protect it and you can only access it from a set of white-listed IP addresses. You can't do a DNS lookup on the address. I'm at the office so my IP address is fine and furthermore, I can connect using tsql, so this part shouldn't be a problem, but this looks like the failure point.

Thoughts?

One other note, actwd.net is our host. So, this isn't totally zany, I just don't know why it doesn't use the IP address I'm handing it.

4

2 回答 2

1

今天的课程 - 在将内容发布到 Stack Overflow 之前 - 我应该注意到我的端口号不知何故从 1433 更改为 1044。不知道我是如何做到的,但这就是问题所在。

SQL Server 期望端口 1433 上的连接。不是 1044。有些日子我真的不喜欢计算机。. . .

于 2012-11-21T16:20:21.983 回答
0

我收到一个 IP 地址错误,因为我的 odbc.ini 指定的是“服务器”设置而不是“服务器名称”设置。前者是实际的服务器,后者是 freetds.conf 中的一个条目。

于 2019-08-12T23:59:33.827 回答