Product Documentation

FairCom ODBC

Previous Topic

Next Topic

Direct Link FairCom DB SQL ODBC Driver

The Open Database Connectivity (ODBC) interface from Microsoft has emerged as the standard mechanism for client applications to access data from a variety of different data sources through a single interface.

To become accessible from ODBC client applications, database environments must provide a software driver on the client system were the application resides. The driver translates the standard ODBC function calls into calls the database server can process, and returns the resulting data to the application.

The FairCom DB SQL ODBC Drivers are now available on Unix systems, including all Linux distributions supported by FairCom. The FairCom DB SQL ODBC implementation uses a method called “direct link” where the ODBC client application links directly to FairCom ODBC libraries, making unnecessary the use of “middleware” ODBC management software to manage ODBC connections and data sources.

In addition, this direct link driver can also be used by Microsoft Windows applications. The direct link approach avoids the necessity of dealing with the ODBC Manager when installing ODBC applications using FairCom’s ODBC driver, which may be advantageous on large scale systems or mass distributed products.

In This Chapter

Linking the FairCom DB SQL Direct Link Driver

Unix/Linux ODBC Managers

Previous Topic

Next Topic

Linking the FairCom DB SQL Direct Link Driver

ODBC client applications that use the FairCom DB SQL ODBC direct link driver must include the following header files in any source modules that make calls to the ODBC API:

#include <sql.h>

#include <sqlext.h>

These files are found in the \FairCom\<version>\<platform>\include directory.

FairCom DB SQL ODBC client applications must link the following libraries to resolve any calls to the ODBC API:

  • \FairCom\<version>\<platform>\lib\sql.odbc\libodbc_c.a
  • \FairCom\<version>\<platform>\lib\sql.odbc\libctesql.a

Previous Topic

Next Topic

Unix/Linux ODBC Managers

Rather than linking directly with the FairCom DB SQL direct link ODBC driver, an application may link with a generic ODBC manager library, which loads the proper ODBC driver at runtime based on a requested DSN. This is the standard ODBC behavior on MS Windows. Unix platforms support various driver managers. One of the most common managers is the open source unixODBC library. For details on other proprietary Unix managers you are referred to their specific documentation.

To configure the unixODBC environment set the ODBCINI environment variable to refer to an .ini file (for example, odbc.ini) with your DSN information in your application environment. If ODBCINI is not set or unable to be opened, the driver will search $HOME/.odbc.ini for connection information.

The following example shows the ODBCINI setting for path /usr/local/unixODBC/etc/:

ODBCINI=/usr/local/unixODBC/etc/odbc.ini;

setenv ODBCINI /usr/local/unixODBC/etc/odbc.ini

Remember to set LD_LIBRARY_PATH with the path of the unixODBC install.

Note: The example below shows the setting for the path /usr/local/unixODBC/lib and c-tree path /home/FairCom/linux.x64.64bit/lib/sql.odbc:

setenv LD_LIBRARY_PATH /usr/local/unixODBC/lib:/home/FairCom/linux.x64.64bit/lib/sql.odbc

Here are typical settings for the FairCom DB SQL Unix ODBC driver to connect to a default server configuration on the local machine.

Note: The example below assumes that FairCom DB is installed in /home/FairCom//linux.x64.64bit:

[ctreeSQL]

Driver = /home/FairCom/linux.x64.64bit/lib/sql.odbc/libctodbc.so

Host = localhost

Database = ctreeSQL

User ID = ADMIN

Password = ADMIN

Service = 6597

Below is information specific to unixODBC. This may vary across installations.

When SQLConnect() is called, unixODBC looks in the location specific by $ODBCINI for a matching DSN, and loads the specified "Driver". The "Driver" value may refer directly to a shared object to load, or another key.

If it is not a shared object, then you need a reference to the "Driver" value wherever the driver manager looks. With unixODBC, it typically looks in /etc/odbcinst.ini.

[CtreeSQLDriver]

Description = ODBC for ctreeSQL

Driver = home/FairCom/linux.x64.64bit/lib/sql.odbc/libctodbc.so

With unixODBC, tracing can be enabled by adding the following to /etc/odbcinst.ini:

[ODBC]

Trace = Yes

TraceFile = /tmp/mytrace.log

This will log all ODBC calls with their parameter values and the return values to the TracingFile.

FairCom DB SQL PHP Example using unixODBC

<?php

$pass=0;

$fail=0;

putenv("ODBCINI=/home/fctech/php-5.3.3/sapi/cli/odbc.ini");

$isc = odbc_connect('fc','admin','ADMIN');

if($isc == FALSE)

{

$fail++;

echo "FAIL - odbc_connect\n";

}else

{

$pass++;

echo "PASS - odbc_connect\n";

}

$test = odbc_exec($isc,"SELECT TOP 1 owner,tbl,creator from systables");

if($test == FALSE)

{

$fail++;

echo "FAIL - odbc_exec\n";

}else

{

$pass++;

echo "PASS - odbc_exec\n";

}

$val = odbc_result_all($test);

if($val == FALSE)

{

$fail++;

echo "FAIL - odbc_result_all\n";

}

TOCIndex