clienteODBC 0.4.x
ODBC datasources configuration under GNU/LiNUX

There are many ways to configure ODBC on GNU/LiNUX (and FreeBSD). clienteODBC uses FreeTDS + unixODBC combination to provide ODBC connectivity.

Usually, freeTDS and unixODBC packages that comes with most popular distributions doesn't works with MS SQL Server connectivity, so maybe you have to download the last releases of these applications from:

Note: If you use Debian testing (03-27-2009), you don't need to download the sources. Your distribution packages works fine. I have no reports about another distributtions excepts Linux Mint that is the one I use and that works fine too.


The next step is to configure ODBC datasources.

freeTDS
freeTDS is a connection driver (really, a set of libraries) that supports TDS protocol. It provides connectivity to all databases that use this protocol (like MS SQL Server™ and Sybase)

To configure freeTDS we have to edit /etc/freetds/freetds.conf file. It seems like this:

[global]
[DB1]
   tds version     = 8.0
   fdump file      = /tmp/freetds
   Driver          = /usr/lib/odbc/libtdsodbc.so
   Setup           = /usr/lib/odbc/libtdsS.so
   client charset  = UTF-8
   host            = 192.168.1.101
   port            = 1433
[DB2]
   tds version    = 8.0
   fdump file     = /tmp/freetds
   Driver         = /usr/lib/odbc/libtdsodbc.so
   Setup          = /usr/lib/odbc/libtdsS.so
   client charset = UTF-8
   host           = 192.168.1.120
   port           = 1433
On this example, DB1 points to a MS SQL Server databased placed on 192.168.1.101 and DB2 to another placed on 192.168.1.120 tds version = 8.0 is a very important line. We must specify 8.0 if we want to connecto to MS SQL Server 2005™
Driver and Setup must reffer to the freeTDS libraries.

Text placed between brackes ([ and ]) is the server's name. We'll use this name on unixODBC configuration file so it's recommended to keep in mind.

unixODBC
The configuration file for unixODBC is /etc/odbc.ini. It seems like this::
[ODBC Data Sources]
   TESTDB= TESTDB DSN
   TESTVIRTUAL = XP VIRTUAL
[TESTDB]
Description   = TESTDB DSN
Driver        = /usr/lib/odbc/libtdsodbc.so
Setup         = /usr/lib/odbc/libtdsS.so
Servername    = DB1
Database      = Colegio
UID           = sa
PWD           = elpasswordAbc123


[TESTVIRTUAL]
Description   = XP VIRTUAL
Driver        = /usr/lib/odbc/libtdsodbc.so
Setup         = /usr/lib/odbc/libtdsS.so
Servername    = DB2
Database      = ColeccionDiscos
UID           = sa
PWD           = elpasswordBcd456

On this file we specify the DSN name and its propertys: Driver: The same that we used on freeTDS.conf

ServerName: the name of the server we want connect to ( this is the name we have to keep in mind from the previous file).

Database: The name of the database we want to connecto to on the Server[name]

UID: Username for the database.

PWD: Password for the database.

Text placed between brackes ([ and ]) in this file is the DSN name we used from our system (i.e. clienteODBC)

How to verify ODBC connectivity
To test our DSNs we can use isql
luis@lacedemonia ~ $ isql TESTDB sa elpassword
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

If the text writed above is showed in our terminal we have finnished! All is ok.
If we have an error message, we can check our configuration files. If they are ok, maybe we must to download newer versions of freeTDS and unixODBC reading carefully its documentation.

Get clienteODBC at SourceForge.net. Fast, secure and Free Open Source software downloads