2

I have installed FreeTDS on my linux. I have created dsn and get connected to mssql server once using isql.

But when I close the connection and try to reopen isql using same previous command I have used to connect it does not allow me and showing me error like

[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[08S01][unixODBC][FreeTDS][SQL Server]Read from the server failed

If i try after few mins then it automatically get connected.

I have tried same in php odbc_connect() as well. Same issue is there as well. my page showing once and if I refresh it lost connection. After few mins it start serving for once.

My freetds.conf file

[MSSQLExample]
host = 192.168.10.151
port = 49172
tds version = 8.0
instance=SQL2014

my odbc.ini file

[MSSQLExample]
Description = SQL server
Driver = FreeTDS
Trace = No
servername=MSSQLExample
Database = <dbname>
port = 49172
LoginTimeout=1200
QueryTimeout=1200
CPTimeout=1200
CPTimeToLive=100

my odbcinst.ini file

[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout       = 120

Please help me to sortout this issue.

Help is highly appreciated.

Dharmang
  • 3,018
  • 35
  • 38
Hardik Soni
  • 71
  • 1
  • 7
  • I have spent two days full for this issue but not able to get the proper solution. I have made same like odbc setup using DSN in windows in one of my local machine, it is working fine. But when I move on linux environment, it is creating this kind of issue. – Hardik Soni Nov 02 '15 at 12:36
  • As per my finding, php is not closing connection somehow. I have tried to close it using odbc_close() but dont know somehow it still keep connection on. – Hardik Soni Nov 05 '15 at 11:08
  • 1
    Warning: wild guess ahead! I'm not familiar with FreeTDS, but this sounds like a connection-pooling issue. I'm guessing the `CPTimeToLive` setting might have something to do with it? (failing to find it on google?!). Also, there seem to be some configuration options here: http://www.freetds.org/userguide/tdspool.htm. I'd suggest to try to switch it off entirely and then see what effect it might have on your application. Alternatively, you could run a profiler on the MSSQL server to see if your connections connect/disconnect/reconnect/.. or not. – deroby Nov 09 '15 at 13:33
  • The freetds.conf seems to be ok. How do you connect to your DB. I use a connection string like: cat myselect.sql | tsql -o fh -S myserver -U db_user -P mypassword -ofhq -t";" > result.csv – Alexander Baltasar Nov 13 '15 at 06:45
  • Hi Alexander, I can connect using tsql on both way, using odbc instancename as well using hostname directly tsql -H 192.168.10.151 -p 49172 -U -P (direct connect) tsql -S MSSQLExample -U -P (connect using DSN entry) – Hardik Soni Nov 16 '15 at 13:05

0 Answers0