2013-08-14 8 views
17

Ich versuche, Verbindung zu einem MSSQL-Server von einem Ubuntu 12.04 Webserver mit FreeTDS und unixODBC auszuführen.FreeTDS funktioniert, aber ODBC kann keine Verbindung herstellen

Mit tsql ich kann mit

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

Kein Problem gibt es mit dem Server verbinden.

Wenn ich versuche, jedoch mit isql zu verbinden, erhalte ich die folgende Fehlermeldung:

~$ 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 

Meine Config-Dateien sind wie folgt:

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 

folgte ich der Installationsanleitung 1. here und 2. here

Warum nicht richtig verbindet, ist isql?
Meine Vermutung ist, dass der Fehler Super offensichtlich ist, aber ich bin einfach zu dumm, es zu sehen: D

Antwort

1

Wenn odbc findet nicht die Datenquelle bedeutet, dass Sie die falschen

Sie bieten wahrscheinlich versuchen, um eine Verbindung zu dbs3, die fehlschlägt, wenn Sie odbc.ini in

haben es nicht

Sie zu [database3] für ODBC

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

Das ist, was ich tue. Ich benutze dbs3 mit tsql: tsql -S dbs3 -U -P . Mit isql die Art, wie Sie erwähnt, gibt diese Fehler – AndMim

+0

Ok haben Sie Datenbank3 zu Ihrem Host-Datei hinzugefügt – meda

+0

Nein, weil von meinem Verständnis, sollte es mit der IP-Adresse in der freetds.conf eingegeben werden – AndMim

11

Die Frage verbinden sollte war diese Linie in odbc.ini

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

Für diejenigen, die auch dieses Problem haben, versuchen Sie auch die

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