DB2 Version 10.1 for Linux, UNIX, and Windows

Sample build scripts and configurations for the unixODBC driver manager

The unixODBC driver manager is an open source ODBC driver manager for use on the Linux and UNIX platforms. The unixODBC driver manager is supported for use with ODBC applications on supported DB2® platforms. There are several build scripts and configurations that you can use with the unixODBC driver manager.

Support statement

If you experience problems with the combination of the unixODBC driver manager and the DB2 ODBC driver after they are properly installed and configured, you can contact the DB2 Service (http://www.ibm.com/software/data/db2/udb/support) for assistance in diagnosing the problem. If the source of the problem lies with the unixODBC driver manager, you can:

Sample build scripts

The following examples are sample build scripts for setting up your environment to use the unixODBC driver manager.

AIX

#! /bin/sh

echo "Unzipping and extracting"
gzip -d unixODBC-2.2.11.tar.gz
tar xf unixODBC-2.2.11.tar

cd unixODBC-2.2.11

#Comment this out if not AIX
export CC=xlc_r
export CCC=xlC_r

echo "Configuring, compiling and installing"
configure --prefix=$HOME --enable-gui=no --enable-drivers=no
make
make install

echo "Setting ini env vars."
export ODBCHOME=~/etc
export ODBCINI=~/odbc.ini

#Comment this out if not AIX
echo "Extracting unixODBC libraries"
cd ~/lib
ar -x libodbc.a
ar -x libodbcinst.a
ar -x libodbccr.a

echo "\n***Still need to set up your ini files"

UNIX (other than the AIX platform)

#! /bin/sh

echo "Unzipping and extracting"
gzip -d unixODBC-2.2.11.tar.gz
tar xf unixODBC-2.2.11.tar

cd unixODBC-2.2.11

echo "Configuring, compiling and installing"
configure --prefix=$HOME --enable-gui=no --enable-drivers=no
make
make install

echo "Setting ini env vars."
export ODBCHOME=~/etc
export ODBCINI=~/odbc.ini

echo "\n***Still need to set up your ini files"

Sample INI file configurations

The following examples are sample user and system INI files for using the unixODBC driver manager.

User INI file (odbc.ini)

The odbc.ini file is in the bin subdirectory of the unixODBC driver manager installation path.
[DEFAULT]
Driver = DB2

[SAMPLE]
DESCRIPTION = Connection to DB2
DRIVER = DB2

System INI file (odbcinst.ini)

The odbcinst.ini file is in the bin subdirectory of the unixODBC driver manager installation path. The Driver entry for each database section must point to the location where DB2 libraries are located.
There are multiple library files that are associated with DB2 ODBC driver. You must specify a DB2 library based on your application environment.
  • For a 32-bit unixODBC driver manager on the AIX® platform, you must specify the libdb2.a library for the Driver entry.
  • For a 32-bit unixODBC driver manager on the Linux and UNIX platform other than AIX, you must specify the libdb2.so library for the Driver entry.
  • For a 64-bit unixODBC driver manager on the AIX platform, you must specify the db2o.o library for the Driver entry.
  • For a 64-bit unixODBC driver manager on the Linux and UNIX platform other than AIX, you must specify the libdb2o.so library for the Driver entry.

The following sample system INI file has the ODBC trace enabled, with the trace log file set to trc.log.

[DEFAULT]
Description = Default Driver
Driver = /u/db2inst1/sqllib/lib/db2o.o
fileusage=1
dontdlclose=1

[DB2]
Description = DB2 Driver
Driver = /u/db2inst1/sqllib/lib/db2o.o
fileusage=1
dontdlclose=1

[ODBC]
Trace = yes
Tracefile = /u/user/trc.log
Note:
  • If you encounter problems when closing the driver manager, such as during SQLDisconnect(), set the value dontdlclose=1 in the odbcinst.ini file, as shown in the sample system INI file.
  • The 64-bit unixODBC driver manager version 2.3.0 and later treats the SQLHANDLE and SQLLEN value as 64-bits in length. The 64-bit unixODBC driver manager versions before the version 2.3.0 treats the SQLHANDLE value as 64-bit in length, but the SQLLEN value as 32-bit in length.