Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to connect to the MS SQL database using freetds and unixodbc. I have read various guides how to do it, but no one works fine for me. When I try to connect to the database using isql tool, I get the following error:

$ isql -v TS username password
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect

Have anybody already successfully established the connection to the MS SQL database using freetds and unixodbc on Ubuntu 12.04? I would really appreciate some help.

Below is the procedure I used to configure the freetds and unixodbc. Thanks for your help in advance!

Procedure

First, I have installed the following packages with:

sudo apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc

and configured freetds as follows:

--- /etc/freetds/freetds.conf ---
[TS]
host = SERVER
port = 1433
tds version = 7.0
client charset = UTF-8

Using tsql tool I can successfully connect to the database by executing

tsql -S TS -U username -P password

As I need an odbc connection I configured odbcinst.ini as follows:

--- /etc/odbcinst.ini ---
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
FileUsage = 1
CPTimeout =
CPResuse  =
client charset = utf-8

and odbc.ini as follows:

--- /etc/odbc.ini ---
[TS]
Description = "test"
Driver = FreeTDS
Servername = SERVER
Server = SERVER
Port = 1433
Database = DBNAME
Trace = No

Trying to connect to the database using isql tool with such a configuration results the following error:

$ isql -v TS username password
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect
share|improve this question

2 Answers 2

Thanks, your post was very useful for me. I was able to get it to work by eliminating the following lines from my odbcinst.ini file

Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
FileUsage = 1
CPTimeout =
CPResuse  =
client charset = utf-8

so now my odbcinst.ini file looks like this:

--- /etc/odbcinst.ini ---
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

and my odbc.ini file looks like this now:

--- /etc/odbc.ini ---
[TS]
Description = "test"
Driver = FreeTDS
Server = SERVER
Port = 1433
Database = DBNAME

Once I simplified everything it worked great. I still can't get it to work with RODBC but it worked with isql.

I don't know if this will help but your post helped me. Thanks.

share|improve this answer
    
Thanks, definitely related to missing driver in /etc/odbcinst.ini –  Dejan Jun 7 '13 at 15:56
    
Thank you, fixed instantly, after hours of frustration –  John Barça Mar 12 at 14:54

Ubuntu prior to 12.04 had a different odbc path in the /etc/odbcinst.ini file.

The old driver path was:

Driver = /usr/lib/odbc/libtdsodbc.so

I changed it to:

Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

Here's the full configuration:

--- /etc/odbcinst.ini ---
[FreeTDS]
Description = tdsodbc
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
FileUsage = 1
CPTimeout = 5
CPReuse = 5

Works like a charm now! Thanks!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.