6

I'm trying to connect to SQL-Azure from Ubuntu 12.04.

I've compiled freeTds-0.91 with openssl and libiconf

tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password

I try connect using the above statement and I get this error:

locale is "en_ZA.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to DatabaseName
Error 20004 (severity 9):
    Read from the server failed
    OS error 104, "Connection reset by peer"
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

My tsql -C output:

Compile-time settings (established with the "configure" script)
                        Version: freetds v0.91
         freetds.conf directory: /usr/local/etc
 MS db-lib source compatibility: no
    Sybase binary compatibility: no
                  Thread safety: yes
                  iconv library: yes
                    TDS version: 5.0
                          iODBC: no
                       unixodbc: no
          SSPI "trusted" logins: no
                       Kerberos: no

I can't seem to find any information on what is causing and how to resolve this issue.

Any help will be much appreaciated.

Martinffx
  • 2,426
  • 4
  • 33
  • 60

4 Answers4

14

The error is caused by the use of the wrong version of TDS.

To resolve just specify the TDS version before the tsql command:

TDSVER=8.0 tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password
Martinffx
  • 2,426
  • 4
  • 33
  • 60
1

Is your IP address whitelisted by the database server? If not, you won't be able to connect.

Paul
  • 3,072
  • 6
  • 37
  • 58
1
in freetds.conf

[servername] 
host = ipAddress
port = 1433
tds version = 8.0

for checking freetds connection
===============================

$tsql -S servername -U username 
password
the-run
  • 977
  • 1
  • 10
  • 21
  • If would be useful if you added an explanation to this answer – Rob Baillie Nov 17 '14 at 11:25
  • Mostly this "Error 20002 (severity 9): Adaptive Server connection failed There was a problem connecting to the server" it is happen due to the miss declaration in freetds.conf . some may holds the file in /etc/freetds.conf and some may keep that in /usr/local/etc. in freetds.conf at the end of the lines add the given piece of code which i was mentioned to put that in freetds.conf... and checking the freetds connection using tsql command. i think it might be useful to you. – the-run Nov 17 '14 at 12:25
0

Do with TDS 8.0 version worked for me.

Just put in /etc/freetds/freetds.conf to stay permanent

fedorqui
  • 275,237
  • 103
  • 548
  • 598