FreeTDS Connector - SQLSTATE[01002] Adaptive Server connection failed (severity 9) - sql-server

I'm facing an issue in API call due to DB connection failure. We have tried for concurrent 90 calls to fetch some details based on some code which got failed in 1 percentage due to DB connection failure. Here is the error message “SQLSTATE[01002] Adaptive Server connection failed (severity 9)” while connecting to the DB. There are so many failures happening recently in API call due to the DB connection failure.
Is there any work around or permanent fix for this issue?
Some info,
rpm -qa | grep freetds
freetds-0.91-2.el6.x86_64 freetds-devel-0.91-2.el6.x86_64
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Please give your hands to fix this issue.

Related

connecting to remote mssql from linux plesk via php

I am trying to connect to remote Microsoft SQL server 2012 service pack 2 database from my Linux machine which is having php 5.3, php-mssql support and mysql version 5.5 enabled. Meanwhile I am getting below error message even if the login details are correct.
The ms-sql database is using Persian collation which cannot be changed. Is there any possible fix for this?
[root#i]# /usr/bin/tsql -H remove-server-ip -p 1433 -U mssql-user
locale is "en_IN"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 4075 (severity 16, state 1) from RAHKARAN Line 1:
"
The USE database statement failed because the database collation
Persian_100_CI_AI is not recognized by older client drivers. Try
upgrading the client operating system or applying a service update to
the database client software, or use a different collation. See SQL
Server Books Online for more information on changing collations."
Msg 18456 (severity 14, state 1) from RAHKARAN Line 1:
"Login failed for user 'mssql-user'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
Error 20002 (severity 9)
Freetds version is below
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes

pyodbc not working on RedHat 5.4. Trying to connect to ms-sql database server using unixODBC and FreeTDS?

I am facing issue while trying to access ms-sql database using pyobdc.
Here is the System config:
Python 2.7.11
Pyodbc 3.0.7
RedHat 5.4 (Tikanga) 32 Bit system
Microsoft SQL Server 2012 (Database server)
unixODBC 2.3.0
$ tsql -C output :
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
$ odbcinst -j output :
unixODBC 2.3.0
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 4
SQLLEN Size........: 4
SQLSETPOSIROW Size.: 2
$ cat /usr/local/etc/odbcinst.ini output :
[ms-sql]
Description=TDS connection
Driver=/usr/local/lib/libtdsodbc.so
Setup=/usr/local/lib/libtdsodbc.so
FileUsage=1
UsageCount=1
$ cat /usr/local/etc/odbc.ini output :
[sqlserverdatasource]
Driver = ms-sql
Description = ODBC connection via ms-sql
Trace = No
Server = >IP Addresss To Database server<
Port = >Port Number<
Database = >Database name<
$ cat /etc/freetds.conf output :
[sql-server]
host = >IP Addresss To Database server<
port = >Port Number<
tds version = 8.0
Command which is giving me error:
connection = pyodbc.connect(r'DRIVER={FreeTDS};SERVER=>IP Addresss To Database server<; PORT=>Port Number<;DATABASE=Database name;UID=Database UID;PWD=DatabasePasswd;')
Error:
Traceback (most recent call last): File "<stdin>", line 1, in
<module> pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver
Manager]Data source name not found, and no default driver specified
(0) (SQLDriverConnect)')
I am trying to solve this problem for last 3 days. But no luck yet. So any help/suggestion would be very helpful.
I have already gone through googling.
Thanks in advance :)
Try something like this:
freetds.conf:
[sql-server]
host = sql-server.host.com
port = 1433
tds version = 7.2
odbc.ini:
[sql-server]
Driver = FreeTDS
Server = sql-server.host.com
Port = 1433
TDS_Version = 7.2
odbcinst.ini:
[FreeTDS]
Description = v0.91 with protocol v7.2
Driver = /usr/local/lib/libtdsodbc.so
In Python:
connection = pyodbc.connect(r'DRIVER={FreeTDS};SERVER=sql-server.host.com;PORT=1433;DATABASE=Database name;UID=Database Username;PWD=DatabasePasswd;TDS_Version=7.2')
TDS Version 8.0 does not exist. 7.2 is the highest supported in FreeTDS 0.91. See here to explain the confusion: http://www.freetds.org/userguide/choosingtdsprotocol.htm
If you're still having issues, try testing with tsql and isql to test the FreeTDS and unixODBC layers of the connection stack respectively. Good luck!

tsql login failed but management studio can connect

I'm trying to connect to a MS SQL Server instance using tsql (to troubleshoot not being able to connect with django-pymssql).
I can connect fine to the server (running on Amazon RDS, latest SQL Server version from on there) from a VM running SQL Server management studio, but from my native Ubuntu 15.10 env I get a login failed error.
Using the following:
tsql -H <hostname> -p 1433 -U <user> -P <mypassword>
I get:
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 18456 (severity 14, state 1) from EC2AMAZ-U1TAK71 Line 1:
"Login failed for user 'sa'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
As I can connect in management studio with mixed mode auth using the same creds I'm suspecting this isn't the real error.
Anyone have any ideas how I can troubleshoot?
tsql -C shows:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Thanks loads for any pointers.!
(Accidentally posted this to AskUbuntu so have moved here. Sorry).
Answering my own question. Turns out it was down to the password being too long. I experimented with it, and any password longer than 30 characters didn't work. Seems to be a known issue with freetds.
Thanks.

Connecting to MS SQL Server with iODBC on Mac

I'm trying to connect to a Microsoft SQL Server from my Mac development machine using iODBC. No matter what I do, I get the error message Unable to connect to data source from the FreeTDS driver. After consulting various manuals, blog posts, and StackOverflow questions, I'm at my wit's end.
I'm using Mac OS X 10.7.4, with FreeTDS version 0.91 installed through Homebrew. Here's what I'm doing:
$ brew install freetds
$ mkvirtualenv odbc
$ workon odbc
$ pip install pyodbc
$ tsql -H localhost -U mydbusername -P mydbpassword -p 1433
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit
The above connects and works, but:
$ iodbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0607.1008
Enter ODBC connect string (? shows list): driver={TDS};server=localhost;uid=mydbusername;pwd=mydbpassword;database=mydbname
1: SQLDriverConnect = [FreeTDS][SQL Server]Unable to connect to data source (0) SQLSTATE=08001
1: ODBC_Connect = [FreeTDS][SQL Server]Unable to connect to data source (0) SQLSTATE=08001
Since I'm ultimately planning to use it through PyODBC, I tried that as well:
$ python
Python 2.7.3 (default, Jun 22 2012, 00:35:38)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> c = pyodbc.connect(driver='/usr/local/lib/libtdsodbc.so', host='localhost', name='mydbname', uid='mydbusername', pwd='mydbpassword')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
I've tried all manner of things suggested in blog posts and SO posts... creating DSNs in ODBC Administrator, creating a ~/.odbc.ini, attempting to use unixODBC (which didn't work with PyODBC), specifying a connection string instead of keyword args, etc. I also produced a trace file through iODBC, which I have pasted here, but I couldn't glean any more information from it than from the error message.
(I should mention that I am tunneling the connection to SQL Server over SSH with the line LocalForward localhost:1433 production.someinstitution.edu:1433 in my ~/.ssh/config, since my IT department has limited me to connect only from the production server's IP. It works for a GUI client (SQuirreLSQL) so I assume the forwarding is correct.)
You should use 'port' parameter in connection string in case of DSN-less connection.
Otherwise your port could be specified in your DSN or driver config (odbc.ini and freetds.conf respectively)

Symfony2 and Microsoft SQL Server on Mac and MAMP

I´m going to develop a Symfony2 application in my Mac OSX with MAMP, but the database (a Microsoft SQL Server one) is in another computer.
I setup everything (I followed this instruction http://jesusomar.com/2011/07/22/mamp-php-and-mssql )and if I check phpinfo() I see that mssql is active, but I´m getting this error:
[PDOException]
could not find driver
any help or clue? Thanks in advance
The first step is to check if FreeTDS is installed. You can run tsql -C to get information about MSSQL libraries in your computer. You should get something like this:
Version: freetds v0.91
freetds.conf directory: /usr/local/Cellar/freetds/0.91/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.1
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
If FreeTDS is not installed, you can do it with Homebrew (for example): brew install freetds.
Now you can use MssqlBundle to connect with your database.

Resources