Usando Caché - ODBC PDF
Usando Caché - ODBC PDF
Usando Caché - ODBC PDF
Version 2008.1
29 January 2008
and
Cach WEBLINK, Distributed Cache Protocol, M/SQL, N/NET, and M/PACT are registered trademarks of InterSystems
Corporation.
and
InterSystems Jalapeo Technology, Enterprise Cache Protocol, ECP, and InterSystems Zen are trademarks of
InterSystems Corporation.
All other brand or product names used herein are trademarks or registered trademarks of their respective companies
or organizations.
This document contains trade secret and confidential information which is the property of InterSystems Corporation,
One Memorial Drive, Cambridge, MA 02142, or its affiliates, and is furnished for the sole purpose of the operation
and maintenance of the products of InterSystems Corporation. No part of this publication is to be used for any other
purpose, and this publication is not to be reproduced, copied, disclosed, transmitted, stored in a retrieval system or
translated into any human or computer language, in any form, by any means, in whole or in part, without the express
prior written consent of InterSystems Corporation.
The copying, use and disposition of this document and the software programs described herein is prohibited except
to the limited extent set forth in the standard software license agreement(s) of InterSystems Corporation covering
such programs and related documentation. InterSystems Corporation makes no representations and warranties
concerning such software programs other than those set forth in such standard software license agreement(s). In
addition, the liability of InterSystems Corporation for any losses or damages relating to or arising out of the use of
such software programs is limited in the manner set forth in such standard software license agreement(s).
THE FOREGOING IS A GENERAL SUMMARY OF THE RESTRICTIONS AND LIMITATIONS IMPOSED BY
INTERSYSTEMS CORPORATION ON THE USE OF, AND LIABILITY ARISING FROM, ITS COMPUTER
SOFTWARE. FOR COMPLETE INFORMATION REFERENCE SHOULD BE MADE TO THE STANDARD SOFTWARE
LICENSE AGREEMENT(S) OF INTERSYSTEMS CORPORATION, COPIES OF WHICH WILL BE MADE AVAILABLE
UPON REQUEST.
InterSystems Corporation disclaims responsibility for errors which may appear in this document, and it reserves the
right, in its sole discretion and without notice, to make substitutions and modifications in the products and practices
described in this document.
For Support questions about any InterSystems products, contact:
InterSystems Worldwide Customer Support
Tel:
+1 617 621-0700
Fax:
+1 617 374-9391
Email:
support@InterSystems.com
Table of Contents
About This Book ................................................................................................................................ 1
1 Overview ......................................................................................................................................... 3
1.1 Introduction ............................................................................................................................ 3
1.2 Supported Driver Managers ................................................................................................... 3
2 Using Cach as an ODBC Data Source on Windows .................................................................. 5
2.1 Overview ................................................................................................................................ 5
2.2 Performing a Stand-alone Installation ................................................................................... 6
2.3 Creating a DSN for Cach on Windows ................................................................................ 6
2.3.1 Creating a DSN by Using the Control Panel ............................................................... 6
2.3.2 Creating a File DSN ..................................................................................................... 9
3 Using Cach as an ODBC Data Source on UNIX ...................................................................... 11
3.1 Overview .............................................................................................................................. 12
3.2 Performing a Stand-alone Installation ................................................................................. 12
3.3 Key File Names .................................................................................................................... 13
3.4 Custom Installation and Configuration for iODBC ............................................................. 14
3.5 Troubleshooting for Shared Object Dependencies .............................................................. 14
3.6 Configuring the ODBC Initialization File ........................................................................... 15
3.6.1 Introduction to the UNIX ODBC Initialization File .................................................. 15
3.6.2 Name and Location of the Initialization File ............................................................. 15
3.6.3 Details of the ODBC Initialization File ..................................................................... 16
3.7 Testing the Cach ODBC Configuration ............................................................................. 18
3.7.1 Using the Select Test Program ................................................................................... 18
3.7.2 Using the Gateway Test Program ............................................................................... 19
4 ODBC Environment Variables .................................................................................................... 21
4.1 CACHEODBCDEFTIMEOUT ............................................................................................ 21
4.2 CACHEODBCPID ............................................................................................................... 21
4.3 CACHEODBCTRACE (UNIX Only) ................................................................................. 22
4.4 CACHEODBCTRACEFILE ................................................................................................ 22
4.4.1 Special Steps for Windows 2003 ............................................................................... 22
4.5 CACHEODBCTRACETHREADS ...................................................................................... 23
5 Logging .......................................................................................................................................... 25
5.1 General Tips ......................................................................................................................... 25
5.2 Enabling Logging for Cach ODBC on Windows ............................................................... 26
5.3 Enabling Logging for Cach ODBC on UNIX .................................................................... 26
List of Figures
Cach ODBC Data Source Setup Dialog Box .................................................................................... 7
The chapter Using Cach as an ODBC Data Source on Windows describes how to use Cach
as a ODBC data source on Windows.
The chapter Using Cach as an ODBC Data Source on UNIX describes how to use Cach as
a ODBC data source on UNIX.
The chapter ODBC Environment Variables describes the environment variables that control
the Cach ODBC client driver.
The chapter Logging describes how to enable logging for Cach ODBC.
The appendix Configuring PHP with iODBC describes how to use the ODBC functionality of
Cach in conjunction with PHP.
The book Using Java with Cach includes information on JDBC connectivity to Cach from
external data sources, the JDBC equivalent of what is described in this manual.
The book Using the Cach SQL Gateway describes ODBC connectivity from Cach to external
data sources, the reverse sense of what is described in this manual.
In addition, any technical bookstore offers a wide selection of books on SQL and ODBC.
Click the Cach cube in the Windows system tray. If Cach is stopped, start it. Then choose
Documentation from the menu.
Entering the following URL into a browser page on the local Cach system, where 57772 is the
port number for which your Cach server is configured:
http://localhost:57772/csp/docbook/DocBook.csp
When you are running Studio, click Help > On-line Documentation.
The PDF files for the Cach books are found in a subdirectory where you installed Cach, usually
C:\InterSystems\Cache\Docs\ or similar. InterSystems strongly recommends that if you want printed
documentation, you do not print HTML pages from the browser, but instead take advantage of these
PDF files, whose content is identical to the HTML.
1
Overview
This chapter provides an overview of Cach ODBC. It discusses the following:
Supported driver managers that you can use with the Cach ODBC driver
1.1 Introduction
Cach ODBC provides ODBC drivers to enable you to access Cach via an ODBC connection. To do
so, you do the following:
Then your application can use the Cach DSN in the same way it would use any other DSN.
On Windows: the Microsoft Windows driver manager provided with the operating system.
On UNIX: the iODBC driver manager (for use with the Unicode and 8bit ODBC APIs) and the
unixODBC driver manager (for use with the 8bit ODBC API).
For questions about other driver managers, contact the InterSystems WorldWide Response Center.
Overview
For more complete information, including specific supported databases, see the Cach Supported
Platforms document.
2
Using Cach as an ODBC Data
Source on Windows
An external application can use Cach as an ODBC data source. This chapter describes how to do this
on Windows.
This chapter discusses the following topics:
How to create DSNs for Cach on Windows via the Windows Control Panel or by creating a file
DSN.
2.1 Overview
To use Cach as an ODBC data source, you do the following:
1.
Install the Cach ODBC client driver. See the Cach Installation Guide or see Performing a
Stand-alone Installation.
2.
3.
Use that DSN within your ODBC-aware applications (such as development tools or report writers).
Each Cach database can be represented by multiple DSNs, each of which can support multiple connections.
Using Cach ODBC 5
ODBCDriver_ia64.exe can only be run on Windows 64-bit Itanium Edition and it will install 64-
ODBCDriver_x64.exe can only be run on Windows x64 Edition and it will install 64-bit ODBC
Use this dialog box to specify the details for a specific Cach ODBC data source. The fields are listed
below and are required unless otherwise specified:
Name
Description
Host IP Address
Host Port Number Specifies the port for connecting to the DSN. The default for Cach is 1972.
Cach Namespace
Authentication Method Select either Password or Kerberos, depending on the security used for
Specifies the IP address of the DSN in dotted decimal or dotted quad form,
such as 127.0.0.1 .
this database.
If you select Kerberos, also specify the following additional settings:
-
with Encryption,
For more information on Kerberos, see the Cach Security Administration Guide.
User Name
Optionally specifies the user name for logging into the DSN. By default, this is
_SYSTEM and is not case sensitive.
Password
ODBC Log
Static Cursors If selected, enables the Cach ODBC client drivers static cursor support. If this
Optionally specifies the password for the account specified by the UID entry. For
the SYSTEM user name, the password is SYS and is case sensitive.
If selected, specifies the creation of a log file of ODBC client driver activities for
all Cach DSNs. This log is for troubleshooting; you should not turn logging on during normal
operation as it will dramatically slow down ODBC performance. For more information on logging,
see the chapter Logging.
flag is off, then the cursor support provided by the ODBC Cursor Library will be used. In general,
this flag should be off unless you have a specific reason for not using the ODBC Cursor Library.
If selected, causes the ODBC client driver to ignore the value of the
ODBC query timeout setting.
Disable Query Timeout
The ODBC query timeout setting specifies how long a client should wait for a specific operation
to finish. If an operation does not finish within the specified time, it is automatically cancelled.
The ODBC API provides functions to set this timeout value programmatically. Some ODBC
applications, however, hard-code this value. If you are using an ODBC application that does not
allow you to set the timeout value and the timeout value is too small, you can use the Disable
Query Timeout option to disable timeouts.
Unicode SQL Types If selected, turns on reporting of a Unicode SQL type ( SQL_WVARCHAR
(-9) SQLType ) for string data. This allows Microsoft Office 2000 and Visual Basic applications
to allocate the properly sized buffers to hold multibyte data. This functionality is only relevant if
you are working with a multibyte character set, such as in Chinese, Hebrew, Japanese, or Korean
locales. If you are only using single-byte character set data, do not select this check box.
If an application encounters a SQL data type out of range error from the Microsoft Driver
Manager using SQLBindParameter, it can be caused by having selected this check box.
After you have created the DSN, you can use the Test Connection button to see if your data source is
working correctly.
On Windows 64-bit, use the Windows Control Panel ODBC Administrator to create user DSNs that
function for both 32- and 64-bit programs. To configure a system DSN for a 32-bit program, run
%SystemRoot%\SysWow64\odbcad32.exe.
A file DSN is invoked via SQLDriverConnect where you specify the file DSN. It can specify an
existing DSN to use, for example,
[ODBC]
DSN=CACHE Samples
If the user ID or password is not supplied as part of the connection parameters, the connection manager
will prompt for them.
Note:
Commonly used file DSNs are usually stored in the following directory:
%SystemRoot%\Program Files\Common Files\ODBC\Data Sources
3
Using Cach as an ODBC Data
Source on UNIX
An external application can use Cach as an ODBC data source. This chapter describes how to do this
on UNIX. It discusses the following topics:
How to perform a stand-alone installation of the Cach ODBC client driver and supported driver
manager on UNIX.
For information on performing a complete installation of Cach, see the Cach Installation Guide.
How to configure the ODBC initialization file, in which you create DSNs for Cach on UNIX.
If you are performing custom configuration of the Cach ODBC driver on UNIX, you should be
familiar with using UNIX, compiling and linking code, writing shell scripts, and other such tasks.
Note:
The sample ODBC initialization file and test files may include the _SYSTEM/SYS or _system/sys username-password pair in unencrypted form. It is recommended that you remove
this data before deployment; it is also recommended that you remove the _SYSTEM account
before deployment.
3.1 Overview
To use Cach as an ODBC data source, you do the following:
1.
Install and configure a Cach ODBC client driver. See the Cach Installation Guide or see Performing a Stand-alone Installation.
2.
Edit the ODBC initialization file to define a DSN for a Cach database.
3.
Use that DSN within your ODBC-aware applications (such as development tools or report writers).
Each Cach database can be represented by multiple DSNs, each of which can support multiple connections.
Create the directory where you wish to install the client, such as /usr/cacheodbc/.
2.
Go to the ./dist/ODBC/ directory on the Cach DVD and run the following command:
# ./cplatname identify
This command displays the name of your platform, which you will use to determine the file you
need.
3.
Copy the appropriate zipped tar file from the Cach DVD into the directory that you just created.
On the Cach DVD, the ./dist/ODBC/ directory contains zipped tar files with names like the following:
ODBC-release-code-platform.tar.Z
where release-code is a release-specific code (that varies among Cach versions and releases) and
platform specifies the operating system that the ODBC client runs on.
4.
Go to the directory you created and manually unpack the .tar file, as follows:
This creates bin and dev directories and installs a set of files.
5.
Run the ODBCInstall program, which will be in the directory that you created. This program
creates several sample scripts and configures cacheodbc.ini under the mgr directory. For example:
# pwd
/usr/cacheodbc
# ./ODBCInstall
For information on performing a complete installation (which includes a full ODBC installation), see
the Cach Installation Guide.
The install-dir/bin/ directory includes the following versions of the Cach ODBC client driver
(depending on your platform):
-
libcacheodbcmiw.dylib The Unicode driver for MAC OS, for the C++ binding.
libiodbc.so The iODBC driver manager, which supports both 8bit and Unicode ODBC
APIs.
libodbc.so The unixODBC driver manager, for use with the 8bit ODBC API.
The install-dir/bin/ directory also includes the following versions of the shared object used by the
Cach SQL Gateway; this enables you to connect from Cach to other ODBC client drivers. These
files are not installed if you perform a stand-alone installation.
-
The files for the test programs are discussed later in this chapter.
Use the appropriate command to list the dynamic dependencies of the Cach ODBC driver.
For example, on Solaris and other platforms, the command is ldd:
# ldd install-dir/bin/libcacheodbc.so
Here install-dir is the directory where Cach is installed. If no dependencies are found, you will
see a message like the following:
libstlport_gcc.so => not found
2.
If there are no errors, then all dependencies are valid; if there are errors, run the following commands to force the shared object loader to look in the current directory:
sh
cd install-dir/bin
LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
The sh command starts the Bourne shell; the cd command changes to the appropriate directory;
and the export command sets the path to look up shared objects.
Note that on AIX, you would use LIBPATH instead of LD_LIBRARY_PATH.
3.
Once you have added the current directory to the path, run ldd again and check for missing
dependencies. If any shared objects cannot be found, add them to the same directory as the ODBC
client driver.
It provides information so that the driver manager can locate and connect to an available DSN,
including the path of the ODBC client driver required for that particular connection.
It defines the DSNs (and optionally includes login credentials for them). The ODBC client drivers
use this information.
The file specified by the ODBCINI environment variable, if this is defined. When defined, this
variable specifies a path and file, such as:
ODBCINI=/usr/cachesys/cacheodbc.ini
export ODBCINI
2.
The .odbc.ini file in the directory specified by the users $HOME variable, if $HOME is defined
and if .odbc.ini exists.
3.
If $HOME is not defined, the .odbc.ini file in the home directory specified in the passwd file.
4.
The file specified by the system-wide SYSODBCINI environment variable, if this is defined. When
defined, this variable specifies a path and file, such as:
SYSODBCINI=/usr/cachesys/cacheodbc.ini
export SYSODBCINI
5.
The file odbc.ini file located in the default directory for building the iODBC driver manager (/etc/),
so that the full path and file name are /etc/odbc.ini.
To use a different odbc.ini file, then you should delete or rename the Cach sample initialization file
to allow the driver manager to search the $HOME or /etc/odbc.ini paths.
ODBC Data Sources Lists all DSNs for the file. Each entry is of the form DSNName=SectionHeading , where DSNName is the name specified by the client application and the
SectionHeading specifies the heading under which DSN information appears in this file.
Driver Specifies the location of the client driver file to use for this DSN. In this case this is the
file libcacheodbc.so.
Host Specifies the IP address of the DSN in dotted decimal or dotted quad form, such as
127.0.0.1 .
UID Specifies the user name for logging into the DSN. By default, this is _SYSTEM and
is not case sensitive.
Password Specifies the password for the account specified by the UID entry. For the SYSTEM
user name, the password is SYS and is case sensitive.
Note:
Port Specifies the port for connecting to the DSN. The default for Cach is 1972.
Protocol Specifies the protocol for connecting to the DSN. For Cach, this is always TCP.
Query Timeout If 1, causes the ODBC client driver to ignore the value of the ODBC query
timeout setting.
The ODBC query timeout setting specifies how long a client should wait for a specific operation
to finish. If an operation does not finish within the specified time, it is automatically cancelled.
The ODBC API provides functions to set this timeout value programmatically. Some ODBC
applications, however, hard-code this value. If you are using an ODBC application that does not
allow you to set the timeout value and the timeout value is too small, you can use the Disable
Query Timeout option to disable timeouts.
Static Cursors If 1, enables the Cach ODBC client drivers static cursor support. If 0, then
the cursor support provided by the ODBC Cursor Library will be used. In general, this flag should
be off (that is, set to 0) unless you have a specific reason for not using the ODBC Cursor Library.
Trace Specifies whether the driver manager performs logging ( on ) or not ( off ); by
default, logging is off.
For more information on logging, see the chapter Logging.
TraceFile If logging is enabled by the Trace entry, specifies the location of the driver manager
log file.
Security Level Specify this if you use Kerberos for authentication. The allowed values are as
follows:
-
0 = Kerberos
Service Principal Name Specify this if you use Kerberos for authentication. This should be the
name of the service principal that represents Cach.
For more information on Kerberos, see the Cach Security Administration Guide.
The select test program, which tests the Cach ODBC driver. You indicate a DSN to use and a
SELECT statement to execute.
The gateway test program, which tests access to Cach via the Cach SQL Gateway.
Tests provided with the unixODBC driver manager; these are not documented here.
select.sh The shell script that runs the test. This script defines the ODBCINI environment
variable (so that the ODBC initialization file can be found), sets up the search path to find the
driver manager, and executes the following SELECT statement:
select * from sample.person where ID < 11
select The executable built from select.c. This is a sample ODBC program already linked with
select.c This is the source code for the select program. This source is provided in case you
The shell script is designed to work with Cach login or unauthenticated modes and in Minimal
or Normal security installations. It may need modification in other cases.
By default, the shell script sets up the search paths to find the iODBC driver manager. You would
change this if you use the unixODBC driver manager or if you install iODBC in a non-default
way.
The script also assumes that the ODBC initialization file is in the install-dir/mgr directory. You
should adjust the script as needed to find the ODBC initialization file on your system.
2.
where dsn is the name of the DSN that you want to use in the test.
This test works as follows:
1.
2.
The select program is linked to a driver manager, which reads the ODBC initialization file to get
connection information for the given DSN.
3.
The driver manager determines the location of the Cach ODBC client driver and loads it into
memory.
4.
The client driver then establishes a TCP/IP connection to the port specified in the ODBC initialization file and is connected to the given Cach namespace using the DSN definition from the
ODBC initialization file.
5.
Once the connection is established, the client application executes your SELECT statement against
the Cach database.
gatewaytest.sh The shell script that runs the test. This script This script defines the ODBCINI
environment variable (so that the ODBC initialization file can be found), sets up the search path
to find the driver manager, and then accesses a DSN named samples, and executes a routine.
This DSN is defined in the sample ODBC initialization file and points to the Cach SAMPLES
namespace.
SQLGatewayTest.ro A routine that makes the callout to the Cach SAMPLES namespace using
iODBC and the Cach ODBC client driver libcacheodbc.so.
Go to install-dir/dev/odbc/samples/select
2.
It starts a Cach session and runs the routine SQLGatewayTest in the SAMPLES namespace.
2.
This application routine then loads a shared object called cgate.so, which is linked against the
iODBC driver manager by default.
3.
The driver manager loads the client driver using information from the ODBC initialization file.
4.
The client driver then establishes a TCP/IP connection to port 1972 and is connected to the Cach
SAMPLES namespace using the DSN definition from the ODBC initialization file.
5.
6.
The routine then fetches the first ten rows of the result set.
The difference between this example and the simple select test is that in this example, the Cach process
making the initial call is the client application. Typically, a Gateway call from Cach calls the DSN
of another vendors database.
4
ODBC Environment Variables
This chapter describes the environment variables that control the Cach ODBC client driver. Typically
you use these only for debugging or diagnostics.
CACHEODBCDEFTIMEOUT
CACHEODBCPID
CACHEODBCTRACEFILE
CACHEODBCTRACETHREADS
4.1 CACHEODBCDEFTIMEOUT
This variable allows you to specify the duration of a timeout for a default login. Its value is in seconds.
4.2 CACHEODBCPID
This boolean variable enables the automatic appending of the process ID number to the log file name.
A value of 1 enables appending and a value of 0 disables it. By default, appending is off.
With CACHEODBCPID enabled, if the base log file is CacheODBC.log and is in your current directory,
then the process ID of 21933 generates a full log file name of CacheODBC.log.21933 .
Both CACHEODBCPID and CACHEODBCTRACEFILE affect the file name. For example, on
Windows if you use CACHEODBCTRACEFILE to set the base file name of the log file (for instance,
Using Cach ODBC 21
to C:/home/mylogs/mylog.txt and enable CACHEODBCPID, then log file names will be of the form
C:/home/mylogs/mylog.txt.21965.
4.4 CACHEODBCTRACEFILE
This variable specifies the location and name of the log file. This can be useful for placing the log file
in a unique directory or giving it a unique name. The default location of the log file is as follows:
For Windows platforms other than Vista, the default location for the log file is %SYSTEMROOT%.
For Vista, the default location for the log file is %PUBLIC%\Logs\CacheODBC.log. This directory
is accessible by all users and allows just one location for the log to be created.
2.
When specifying the log file information, you also have the option of defining the
CACHEODBCPID environment variable to include PID information. To do this, create another
new variable with a name of CACHEODBCPID and a value of 1.
3.
Create the directory C:\ODBC_Logs and grant universal write access to this directory.
4.
Activate ODBC logging by selecting the ODBC Log check box in the DSN setup screen.
CACHEODBCTRACETHREADS
4.5 CACHEODBCTRACETHREADS
This variable controls whether the log also includes threading information. If the variable is 1,
threading information is included; if it is 0, threading information is not included.
It can be useful to enable this additional kind of logging, if you need to debug a threaded application.
However, it adds many extra lines to the log for most ODBC applications.
5
Logging
This chapter describes how to enable logging when you need to perform troubleshooting. It discusses
the following topics:
General tips
CAUTION:
Enable logging only when you need to perform troubleshooting. You should not enable
logging during normal operation, because it will dramatically slow down performance.
Set the value of the ^%ISCLOG global to 2 in the Cach Terminal as follows:
Set ^%ISCLOG = 2
Enable logging for Cach ODBC, as appropriate. See the later sections of this chapter.
3.
Run your application, ensuring that you trigger the error condition.
4.
Check all the logs for error messages or any other unusual activity. The cause of the error is often
obvious.
Logging
To enable logging for the client driver, find the definition of the DSN that you want to log. Different
kinds of DSN are on different tabs. Click the appropriate tab. Look for a check box labeled ODBC
Log (or Log or variations) and select it.
To enable logging for the driver manager, click the Tracing tab and then click the Start Tracing
Now button.
The Log file Path field determines the location of the trace file.
To enable logging for the client driver, use the CACHEODBCTRACE environment variable. Also
configure the ODBC initialization file. For information on CACHEODBCTRACE, see ODBC
Environment Variables, earlier in this book.
To enable logging for the driver manager, set the Trace entry in the ODBC initialization file. In
the same file, the TraceFile entry specifies the name of the log file to create. For information on
the initialization file, see the section Introduction to the UNIX ODBC Initialization File, earlier
in this book.
A
ODBC Connectivity
This appendix reviews the general architecture of ODBC connectivity.
The client application An application makes calls according to the Microsoft ODBC API.
ODBC calls establish a connection from the client to a data source; see the following section,
ODBC Connection Details.
The ODBC driver manager The driver manager accepts calls from applications using the
ODBC API and hands them off to a registered ODBC client driver. The driver manager also performs any necessary tasks so that the client application can communicate with the client driver
and, ultimately, the database server.
The ODBC client driver A database-specific application that accepts calls from a client
application through the ODBC driver manager and provides communication to the database server.
It also performs any ODBC-related data conversions that the application requests.
The database server The actual database ultimately receiving the calls from the client application. It can be on the same or a different machine than the client driver from which it is receiving
calls.
An initialization file A set of configuration information for the driver manager; depending on
the operating system, it may also contain client driver information. On UNIX, this is an actual
file, frequently called odbc.ini. On Windows, it is a registry entry.
ODBC Connectivity
Note:
For a particular vendor database, that vendor may offer its own version of the ODBC client
driver for that platform. Oracle, for example, supplies its own ODBC driver for use with
Oracle databases on Windows. This may be preferred in some cases because the vendor
driver may take advantage of its knowledge of how the database works internally to optimize
performance or enhance reliability.
Information on locating and accessing the database. For example, this may include the server on
which the database resides and the port to use when connecting to it. The details needed depend
upon the database technology.
In most cases, this information is stored within a DSN (data source name), which has a logical name
for use within the client application. The DSN may or may not include login credentials, which can
also be stored in the database initialization file, or not stored at all.
The DSNs must be registered with the ODBC driver manager.
In practice, a connection is established as follows:
1.
A client application includes ODBC calls that attempt to connect to a particular DSN. A client
application is linked to an ODBC driver manager, which accepts the calls.
2.
The ODBC driver manager reads the initialization file to obtain the location of the ODBC client
driver and load the client driver into memory.
3.
Once loaded into memory, the ODBC client driver uses the ODBC initialization file to locate
connection information for the DSN, as well as other information. Using this information, the
client driver connects to the specified database.
4.
Having established the connection, the client driver maintains communications with the database
server.
B
Configuring PHP with iODBC
You can use the ODBC functionality of Cach in conjunction with PHP (PHP: Hypertext Processor,
which is a recursive acronym). PHP is a scripting language that allows developers to create dynamically
generated pages. The process is as follows:
1.
Get or have root privileges on the machine where you are performing the installation.
2.
b.
c.
Configure the driver manager for use with PHP as described at the iODBC Web site
(www.iodbc.org).
Note that LD_LIBRARY_PATH (LIBPATH on AIX) in the iODBC PHP example does not get set,
due to security protections in the default PHP configuration. Also, copy libiodbc.so to /usr/lib and
run ldconfig to register it without using LD_LIBRARY_PATH.
3.
Download the PHP source kit from http://www.php.net and un-tar it.
4.
Download the Apache HTTP server source kit from http://httpd.apache.org/ and un-tar it.
5.
6.
Build the Apache HTTP server, install it, and start it.
7.
Test PHP and the Web server using info.php in the Apache root directory, as specified in the
Apache configuration file (often httpd.conf). The URL for this is http://127.0.0.1/info.php.
8.
Copy the Cach-specific initialization file, cacheodbc.ini to /etc/odbc.ini because this location
functions better with the Apache Web server if the $HOME environment variable is not defined.
9.
Configure and test the libcacheodbc.so driver as described in the manual Using Cach ODBC.
10. Copy the sample.php file from the Cach ODBC kit to Apache root directory (that is, the directory
where info.php is located), and tailor it to your machine for the location of Cach.
11. You can then run the sample.php program, which uses the Cach SAMPLES namespace, by
pointing your browser to http://127.0.0.1/sample.php
Index
how used, 27
login credentials within, 28
sample, 11
Symbols
^%ISCLOG global, 25
$HOME environment variable, 15
C
Cach database
creating a ODBC DSN on UNIX, 15
creating a ODBC DSN on Windows, 6
using as an ODBC data source on UNIX, 11
using as an ODBC data source on
Windows, 5
Cach ODBC
enabling logging, 25
CACHEODBCDEFTIMEOUT environment
variable, 21
CACHEODBCPID environment variable, 21
CACHEODBCTRACE environment variable, 22
CACHEODBCTRACEFILE environment
variable, 22
CACHEODBCTRACETHREADS environment
variable, 23
CACHEODBCTRACE variable, 26
client driver, ODBC
environment variables (UNIX), 21
file names, 13
installing on UNIX, 12
installing on Windows, 5
introduction, 27
testing on UNIX, 18
D
driver managers (ODBC)
enabling logging, 26, 26
file names, 13
initialization file, 15
installing on UNIX, 14
introduction, 27
supported products, 3
DSNs
creating on UNIX, 15
creating on Windows, 6
E
environment variables for ODBC client driver
UNIX, 21
errors, 25
F
file DSNs, 9
G
gatewaytest.sh file, 19
H
Hypertext Processor scripting language, 29
I
iODBC
custom build or installationng, 14
file names, 13
initialization file, 15
introduction, 3
L
LBPATH environment variable, 14
LD_LIBRARY_PATH environment variable, 14
logging, 25
login credentials
in ODBC connection details, 28
in sample initialization file, 16
O
ODBC
accessing Cach via, on UNIX, 11
accessing Cach via, on Windows, 5
enabling logging for UNIX, 26
enabling logging for Windows, 26
P
PHP, 29
S
sample initialization file
login credentials within, 16
select.* files, 18
shared object dependencies, 14
SQLGatewayTest.ro file, 19
SYSODBCINI environment variable, 15
T
tracing, 25
U
unixODBC
file names, 13
introduction, 3