helpinghand
search
needassistance
 
How To
unixODBC - An open source ODBC Driver Manager
Categories: ODBC, System Management, Tools and Interfaces
Introduction

This article describes howto install and use unixODBC with Mimer SQL.

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.

To achieve runtime portability when accessing different databases an ODBC Driver Manager loads ODBC database drivers on behalf of the application. The unixODBC product is an ODBC Driver Manager, based on an open source implementation, with Linux as its main target platform. However, it is also available for other platforms. For details about unixODBC, see www.unixodbc.org.

Note that unixODBC can be used for free by both commercial and non-commercial operations.

Description

Mimer SQL implements ODBC as one of its native interfaces. Using ODBC with Mimer SQL is therefore as effective as any other database API.

From version 2.2.8 of unixODBC, the Driver Configuration GUI component for Mimer SQL (libmimerS.so) is included in the unixODBC distribution. This enables for Mimer SQL and its ODBC Driver to be configured by the ODBCConfig configuration tool that comes with unixODBC. This configuration tool is used in the continued description below.

The so called Setup library, libmimerS.so, can also be used by other tools dealing with ODBC drivers.

Environment

The ODBC driver for Mimer SQL is included in the libmimer.so library of the Mimer SQL installation.

The description below has a starting point where Mimer SQL is installed and unixODBC is not. "2.2.8" is used as the product version for unixODBC, but any later version number would do.


Downloading

To get the unixODBC source-code, go to www.unixodbc.org and click the Download button.

Note: On Linux systems, unixODBC usually is pre-installed, but it may be of interest to download and use the latest version.

Unpacking

Once you have successfully downloaded unixODBC, you must unpack it. Select a base directory for the package, for example, /opt or your home directory.

To unpack the unixODBC source-code, type:
$ tar -zxmf unixODBC-2.2.8.tar.gz

Or, if tar doesn’t support the z option, type:
$ gunzip unixODBC-2.2.8.tar.gz
$ tar xvf unixODBC-2.2.8.tar


Installing

You should now have a directory named unixODBC-2.2.8. To continue with the installation you should move to that directory:
$ cd unixODBC-2.2.8

Read the INSTALL file, located in your unixODBC directory for more details about your installation.

To see all options available when configuring your unixODBC installation, type the following:
$ ./configure –help

The next step is to perform the installation of unixODBC. The installation procedure follows the de-facto standard for installing this kind of software, i.e. configure, make, make install.

  1. To configure and generate makefiles, execute the following command from your unixODBC-2.2.8 directory (you can usually use all default options):
    $ ./configure

  2. When unixODBC is configured for your platform it is time to compile and link:
    $ make

  3. To install generated files into the installation directory (in this case the default /usr/local), use the following command:
    $ make install


ODBC Driver definition

When the unixODBC installation is completed, it is time to do some definitions needed to access the database. First we should define the Mimer ODBC Driver.

Start the /usr/local/bin/ODBCConfig program from you desktop. Select the "Drivers" tab and push the "Add" button.

For the Driver item, navigate to the libmimer.so library (usually found in /usr/lib). For the Setup item, navigate to the /usr/local/lib/libmimerS.so library.

In the example below we have given this driver definition the name "mimer_odbc":



When the driver name is given and the libraries for Driver and Setup are located, the defined driver will look as follows:



This operation has updated the /usr/local/etc/odbcinst.ini file:
$ cat /usr/local/etc/odbcinst.ini
[mimer_odbc]
Description =
Driver = /usr/lib/libmimer.so
Setup = /usr/local/lib/libmimerS.so
FileUsage = 1
CPTimeout =
CPReuse =

#

Of course, the odbcinst.ini file can be edited manually.

Note that all installed drivers must be registered in the odbcinst.ini file. For details on the odbcinst.ini file, see www.unixodbc.org/odbcinst.html.


DSN definition

When having the driver defined it is time to define a data source, or DSN (Data Source Name), for the database access.

Again, from the ODBCConfig program select one of the "User DSN" or "System DSN" tabs and push the "Add" button.

After you have selected a driver from the given list (select a driver and push "OK"), you will get a window where properties for the data source should be given. In the example below we have choosen the "mimer_odbc" driver that we defined above. The properties "Name", "Database", "Host" and "Port" are required while the rest are optional. (Note that port 1360 is a predefined choice since it is registered for Mimer SQL use).

In the example below we have given this DSN definition the name "mimer_dsn":



When properties are registered the created DSN, in this case a System DSN, will look as follows:



If a System DSN was created, this operation has updated the /usr/local/etc/odbc.ini file:
# cat /usr/local/etc/odbc.ini
[mimer_dsn]
Description = mimer_odbc
Driver = mimer_odbc
Database = mimer_db
Host = host_computer
Port = 1360
User = SYSADM
Password =
Trace = Yes
TraceFile = /home/pelle/odbctrace.log

#


If a User DSN was created, the operation would have updated the .odbc.ini file located in the current user's home directory.

Of course, the odbc.ini file can be edited manually.


The odbc.ini file structure

As you can see, the file odbc.ini is used to store information on the data sources available. For details on the odbc.ini file, see www.unixodbc.org/odbcinst.html.

In general, the odbc.ini file (or .odbc.ini) begins with a part introduced by the header [ODBC Data Sources], where all available data sources are listed. This area is followed by one or more data source entries where information specific to each data source is stored:

[ODBC Data Sources]
data-source-1=vendor-1
data-source-2=vendor-2

[data-source-1]
Driver=vendor-1-driver
Database=vendor-1-database-server
Trace=Yes/No
TraceFile=trace-file


Environment variables

To be able to locate the ODBC Driver Manager library (libodbc.so) in runtime you may need to define the LD_LIBRARY_PATH environment variable to include the directory path to where the library resides:
$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"

If using a system wide odbc.ini file, you must set the environment variable ODBCINI to specify it. If you don’t, Mimer ODBC won’t currently be able to locate it and the mapping between the data source name to the database name cannot be performed.
$ export ODBCINI=/usr/local/etc/odbc.ini

Example

In the unixODBC distribution a SQL query program called isql is included. You can use isql to verify the unixODBC installation and setup. In the example below we are using the database "mim_db" and the DSN "mim_dsn".

  1. Make sure you have done a proper DSN setting, it should correspond to the following:
    [mim_dsn]
    Description = DSN for mim_db
    Driver = mimer_odbc
    Database = mim_db
    Host = localhost
    Port = 1360
    User =
    Password =
    Trace = No
    TraceFile =

  2. The Mimer SQL database server should be started. Use the bsql command, delivered with Mimer SQL, to verify the direct Mimer SQL access:
    $ bsql -uSYSADM -ppassword mim_db

    This should lead to an SQL> command prompt. Try the command "SELECT * FROM MIMER.ONEROW;"

  3. Then you should verify the ODBC access, using isql:
    $ /usr/local/bin/isql mim_dsn SYSADM password

    This should also lead to an SQL> command prompt. Try the command "SELECT * FROM MIMER.ONEROW"


Hopefully you are now up and running, using ODBC towards Mimer SQL with unixODBC as the ODBC Driver Manager.


Benefits

ODBC provides a portable database access layer, which means that various data sources can be accessed by the application.

The ODBC API in Mimer SQL is implemented as a native interface which gives superior performance.

Links

Read more about ODBC and Mimer SQL in the ODBC Database API description.

www.unixodbc.org - unixODBC’s site.

www.iodbc.org - iODBC is another open source ODBC project.

Last updated: 2004-02-24

 

Powered by Mimer SQL

Powered by Mimer SQL