Monday 4 March 2013

How to install unixODBC on linux system


How to install unixODBC  on linux system

Open DataBase Connectivity (ODBC) is a cross-platform, call-level interface that allows applications to access data in any database for which there is an ODBC driver. Using ODBC, you can create database applications with access to any database for which your end-user has an ODBC driver. ODBC provides an API that allows your application to be independent of the source database management system (DBMS). This enables for software developers to write open database programs without the need of a proprietary interface
 1) download software
2) untart the files

gunzip  unixODBC-2.3.1.tar.gz
tar xvf unixODBC-2.3.1.tar
cd unixODBC-2.3.1

3) to install the unixodbc run below command

./configure  --libdir=/usr/lib64 --sysconfdir=/etc --enable-gui=no --enable-drivers=yes --enable-drivers-conf=yes
Make
make install
 

--enable-drivers: This parameter enables building the drivers that were installed by default in previous versions.

--enable-drivers-conf: This parameter enables building the driver configuration libraries that were installed by default in previous versions.
4) verify  the  installtion

]# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

5) Specify the Driver location in odbcinst.ini file


vi   /etc/odbcinst.ini

[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/pgsql-9.1/lib/psqlodbcw.so
Setup           = /usr/lib64/libodbcpsqlS.so.1.0.0
FileUsage       = 1

6) Set  database connection information in odbc.ini file and specified the driver which you have mentioned in odbcinst.ini file

vi : /etc/odbc.ini

[MYDATA]
Driver                = PostgreSQL
Description           = PostgreSQL ODBC
Servername            = xyz
Port                  = 5432
Database              = mydb
Username              = myuser
Password              = pass
ReadOnly              = false
ShowSystemTables      = false
LegacySQLTables       = false
LoginTimeout          = 0
QueryTimeout          = 0
DateFormat            = 1
NumericAsChar         = false
SQLBitOneZero         = false
StripCRLF             = false
securityLevel         = preferredUnSecured
caCertFile            =


[ODBC]
IANAAppCodePage=4
InstallDir=/opt/odbc32v51
Trace=0
TraceDll=/opt/odbc32v51/lib/odbctrac.so
TraceFile=odbctrace.out
UseCursorLib=0

7) Export the environment variable

]#  export ODBCSYSINI=/etc
]# export ODBCINI=/etc/odbc.ini

8) test connection

]#  isql -v  MYDATA
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+

# query system dsn's

]#odbcinst -q -s
[MAYADATA]

Dltest -> is a utility used to check a share library to see if it can be loaded and if a given symbol exists in it.
Isqlà is an utility which can be used to submit SQL to a data source and to format/output results. It can be used in batch or interactive mode.
Iusql -> provides the same functionality as the isql program.
odbc_config -> is used to find out details about the installation of the unixODBC package.
Odbcinst->is an utility created for install script/RPM writers. It is a command line interface to key functionality in the libodbcin

No comments: