Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test ODBC entry on Unix

Tags:

linux

unix

odbc

Does anyone know a way of testing if an odbc entry on the odbc.ini file is configured correctly?

I would like to know if my linux server is able to connect to my SQL Server using an ODBC entry I configured.

like image 701
Diego Avatar asked Mar 30 '12 15:03

Diego


2 Answers

If you are using unixODBC as the ODBC driver manager then just do:

isql -v mydsn myusername mypassword
like image 86
bohica Avatar answered Oct 29 '22 10:10

bohica


The most common problem is that the default source build setup is set to /usr/local/etc, not /etc, so you (as me) may be look at a nice config file but unused.

To verify it, just run

# odbc_config --odbcinstini
/usr/local/etc/odbcinst.ini

A simple symbolic link solve it.

Another problem can be a missing library, that you can verify by running the ldd. ex:

# ldd /opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0 | grep "not found"
        libodbcinst.so.1 => not found

In this case, I need to put the libodbcinst.so.1 in LD_LIBRARY_PATH or in any directory in use by /etc/ld.so.conf. If you choose to put in ld directories, do not forget to run ldconfig as root after it to update ldd cache file.

like image 32
ton Avatar answered Oct 29 '22 09:10

ton