2013-08-14 4 views
17

Я пытаюсь запустить подключение к серверу MSSQL с веб-сервера Ubuntu 12.04 с помощью FreeTDS и unixODBC.FreeTDS работает, но ODBC не может подключиться

Использование TSQL я могу подключиться к серверу с

~$ tsql -S dbs3 -U <username> -P <password> 

Нет проблем нет.

Когда я пытаюсь соединиться с ISQL однако, я получаю следующее сообщение об ошибке:

~$ isql -v database3 <username> <password> 
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source 
[01000][unixODBC][FreeTDS][SQL Server]Unknown host machine name. 
[ISQL]ERROR: Could not SQLConnect 

Мои файлы конфигурации следующим образом:

odbc.ini

[database3] 
Driver=FreeTDS 
TDS_Version=8.0 
Servername=dbs3 
Port=1433 
Database=benchmark_res 

odbcinst. ini

[FreeTDS] 
Description=FreeTDS v0.91 
Driver=/usr/local/lib/libtdsodbc.so 
Setup=/usr/local/lib/libtdsS.so 
Trace=Yes 
TraceFile=/tmp/freetds.log 
ForceTrave=Yes 
UsageCount=1 

freetds.conf

# 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 

[dbs3] 
    host = <server-ip> 
    port = 1433 
    tds version = 8.0 

Я следовал инструкциям по установке 1. here и 2. here

Почему не ISQL соединяющую правильно?
Я думаю, что ошибка супер очевидно, но я просто слишком глуп, чтобы видеть: D

ответ

1

Если ODBC не найти источник данных это означает, что вы обеспечиваете неправильный один

Вы, вероятно, пытаетесь для подключения к dbs3 который потерпит неудачу, если вы не имеете его в odbc.ini

вы должны подключиться к [database3] для ODBC

isql -v database3 <username> <password> 
+0

Вот что я делаю. Я использую dbs3 с tsql: tsql -S dbs3 -U -P . Использование isql, как вы упомянули, возвращает эти ошибки – AndMim

+0

Хорошо, вы добавили базу данных3 в свой файл хоста – meda

+0

Нет, потому что, с моей точки зрения, это должно быть разрешено с помощью IP-адреса, введенного в freetds.conf – AndMim

11

проблема была эта линия в odbc.ini

[database3] must be [dbs3] in your case. 

Для тех, кто также с этой проблемой, Проверьте также

ServerName = *Points to the name of the server configured in freetds.conf*