Integrate Informix ODBC applications on Mac OS X with Informix Dynamic Server, Part 1: Installing and registering the ODBC bundle driver graphically

Exploring Informix CSDK ODBC connectivity on Mac OS X using Apple's Graphical Data Source Utilities

Learn about the new Mac OS X ODBC features available with Informix® Client-SDK and Connect 3.50.xC3. In Part 1 of this 2-part series, see how the ODBC features integrate fully with native Mac OS X applications. In Part 2, you'll follow a series of detailed walkthroughs using FileMaker Pro and OpenOffice.org.

Share:

Ranjani M. Bettadahalli (ranjani_bm@in.ibm.com), Software Engineer, IBM

Ranjani BettadahalliRanjani Bettadahalli is a software developer on the Common Application Development team, specializing in Informix Client-SDK (CSDK) development. She worked on porting and enhancing the CSDK product on Mac OS X for 32-bit and 64-bit applications and is also interested in other Mac-related technologies.



Paul-John To (pjto@us.ibm.com), Software Engineer, IBM

Paul-John ToPaul-John "PJ" A. To is a Software Engineer on the Informix Dynamic Server (IDS) Development Team. His projects over the past three years include developing the IDS and CSDK installation applications for Mac OS X, the IDS Deployment Wizard, IDS Configuration Wizard, and automatic DRDA configuration. In his spare time, he enjoys traveling and playing the piano.



16 April 2009

Introduction

The newly-released 32-bit Informix Client-SDK for the Mac OS X platform provides enhanced Open Database Connectivity (ODBC) capabilities, thereby enabling ODBC-aware applications to integrate seamlessly with Informix Dynamic Server (IDS).

The ODBC driver is provided as a dynamic library and as an application plug-in on Mac OS X. Developers that directly invoke the ODBC API through their applications can use the dynamic library, while Apple's ODBC data source administrator utility uses the plug-in. The product installer copies the libraries, creates the necessary configuration files, and updates the system configuration automatically.

All applications can share a single instance of the driver. Once driver configuration is complete, data sources can be added through the ODBC Administrator utility built into the operating system and made available to ODBC-aware applications, such as Microsoft® Excel and Apple’s native data source utilities, such as FileMaker Pro, OpenOffice.org, and iODBC SDK with iodbctest.

Understanding the Informix ODBC driver file types available for Mac

The bundle file: .bundle (plug-in file)

The .bundle extension is a file extension used for plug-in files that adds extra features to the operating system or an application in Mac OS X. The example in this article uses the bundle module of the Informix ODBC driver (iclit09b.bundle), which was built using required Mac-specific bundling flags -bundle -flat_namespace -undefined suppress. Listing 1 shows the plug-in file format.

Listing 1. Plug-in file format
iclit09b.bundle:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00      BUNDLE    10       1920   DYLDLINK

The dynamic library file: .dylib (dynamic library file)

A file with .dylib extension is a dynamic library file that contains declarations and functions a Mac OS X application references. The example in this article uses the dynamic library module of the Informix ODBC driver (iclit09b.dylib), which was built using the required Mac-specific dynamic build flags -dynamiclib -dynamic -undefined dynamic_lookup. Listing 2 shows the dynamic library file format.

Listing 2. Dynamic library file format
iclit09b.dylib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64  X86_64        ALL  0x00       DYLIB    12       1976   NOUNDEFS DYLDLINK 
                                                                    TWOLEVEL 
                                                                    NO_REEXPORTED_DYLIBS

Distribution location of Informix ODBC Driver files on Mac OS X inside CSDK product

Both the types of Informix ODBC driver files (iclit09b.bundle and iclit09b.dylib) for CSDK Mac OS X 32-bit and CSDK Mac OS X 64-bit products are shipped together inside $INFORMIXDIR/lib/cli.


Installing and registering an ODBC driver

The Informix Client-SDK installer automatically installs and configures the Informix ODBC driver for use on Mac OS X. The process consists of two phases: installation and registration. The installation process is documented in the IBM Informix Client Products Installation Guide (see Resources). Some key points to remember:

  • Registration configures the system to recognize the Informix ODBC driver.
  • The driver can be installed in multiple locations on the same system.
  • Only the first installation of the Informix ODBC driver is registered with the system.

In order to register the plug-in from a different location, do one of the following:

  • Uninstall the registered plug-in and then install the product in the new location.
  • Manually reconfigure the system to use the new location, as described later in this article.

When uninstalling the product, you have the option to retain the global INFORMIXSQLHOSTS file for future Informix client installations to use.

Figure 1. The uninstaller application prompting to remove the INFORMIXSQLHOSTS file
The IBM Informix ODBC driver will be uninstalled. You can also remove the sqlhosts file specified by the INFORMIXSQLHOSTS environment variable, which stores client-server connectivity information for all Informix products. Do you want to remove the sqlhosts file?

Configuring the system environment files and variables

The Client-SDK and Informix Connect installers configure several system files for the Informix ODBC driver.

/Library/ODBC/odbcinst.ini

If the product was installed into the default location /Applications/IBM/informix, the following lines are appended:

[ODBC Drivers]
IBM INFORMIX ODBC DRIVER=Installed

[IBM INFORMIX ODBC DRIVER]
Driver=/Applications/IBM/informix/lib/cli/iclit09b.bundle
Setup=/Applications/IBM/informix/lib/cli/iclit09b.bundle
APILevel=1
ConnectFunctions=YYY
DriverODBCVer=03.51
FileUsage=0
SQLLevel=1
smProcessPerConnect=Y

If the file does not exist, the installation application creates it.

The same configuration can be edited using the ODBC administrator utility built into Mac OS X, which is located in the Utilities folder inside the Applications folder.

Figure 2. List of Installed ODBC drivers on Mac OS X
ODBC Driver List on Mac OS X

After selecting the Informix ODBC driver and clicking Configure, a configuration dialog appears. The ODBC attributes for the Informix driver are displayed.

Figure 3. ODBC driver configuration
Informix ODBC Driver Configuration on Mac OS X

The location of the driver and setup files can be specified by clicking the Choose button. Figure 4 shows the selection of the file within /Applications/IBM/informix/lib/cli.

Figure 4. Browsing for the location of the driver file
Browse for the driver file

INFORMIXSQLHOSTS file

The installer places a copy of the demo sqlhosts file under /etc/InformixODBC. Specify your host connection information, including server name, network protocol, host name, service, and port. Each Informix DSN needs to have a corresponding entry in this sqlhosts file. An example of such an entry might look like the information in Table 1.

Table 1. Format of the INFORMIXSQLHOSTS file
Column 1 (IDS server name)2 (Connection protocol)3 (Host name)4 (Service from /etc/services or port number)5 (Optional connection settings)
odbc_demoonsoctcpclipperturbocsm=(SPWDCSM)

For a list of supported protocols, consult the Informix ODBC Programmer's Guide (see Resources).

Configuring launch services

Mac OS X applications use the Launch Services facility (launchd) to start up. In order to load the ODBC driver successfully, the Launch Services facility must have access to the same environment variables the driver requires. The installer adds the following setenv commands to the /etc/launchd.conf file. If he file does not already exist, the installation application creates it.

Note: the backslashes are indicated for publication purposes only. In practice, the lines separated by a backslash must appear on a single line.

setenv INFORMIXDIR /Applications/IBM/informix
setenv INFORMIXSQLHOSTS /etc/InformixODBC/sqlhosts
setenv ODBCINI /Library/ODBC/odbc.ini
setenv DYLD_LIBRARY_PATH /Applications/IBM/informix/lib: \
	/Applications/IBM/informix/lib/cli: \
	/Applications/IBM/informix/lib/esql

For more information about the launchd.conf file, see the launchd documentation, or enter man launchd.


Discovering differences between a System DSN and a User DSN and their creations

Suppose you need to create and maintain a separate set of data source definitions. Because the changes to /etc/launchd.conf affect the entire system, you need to override the system-wide ODBCINI and INFORMIXSQLHOSTS environment variables. You can do this by creating or editing a property list file within the user's home directory. For example, in order to enable user John to use the sqlhosts file and data sources defined in his home directory, perform the following steps.

  1. Create a file ~/.MacOSX/environment.plist in John's home directory. If a folder called .MacOSX does not exist under the home directory, create it.
  2. Using a text editor, enter the text in the following code section into environment.plist. Alternatively, you can use the Property List Editor included with the Apple Developer tools to create the file.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
    	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>INFORMIXSQLHOSTS</key>
            <string>/Users/John/sqlhosts</string>
            <key>ODBCINI</key>
            <string>/Users/John/Library/ODBC/odbc.ini</string>
    </dict>
    </plist>

The new settings will take effect the next time the user logs into the system.


Enabling connectivity

The following sections walk through the process of enabling connectivity between an ODBC client application and a running instance of IDS.

Creating DSN and establishing connectivity with the server

Creating an Informix ODBC data source consists of entering server connection information in the /etc/InformixODBC/sqlhosts file and specifying the connection parameters within the ODBC Administrator tool. To create a data source, perform the following steps:

  1. If you need to set up a new server connection, open /etc/InformixODBC/sqlhosts in a text editor and add a line indicating the server connection details required to locate the database server, as described in the INFORMIXSQLHOSTS section. This file is present on the file system only after Client-SDK or I-Connect have been installed.
  2. Launch the ODBC Administrator tool, by selecting Applications > Utilities.
    Figure 4. The System DSN tab
    System DSN tab
  3. Click the System DSN tab, and then click the Add button.
    Figure 5. Driver selection dialog box
    Driver selection dialog box
  4. Select IBM INFORMIX ODBC DRIVER, and click OK.
    Figure 6. Enter a Data Source Name and optional description
    Enter a Data Source Name and optional description
  5. Enter a name for this data source and, optionally, a description. Click OK.
  6. Click the Add button. A new row appears in the table with the words Key and Value.
  7. Click Key twice to edit it. Type in UID, and press Enter.
  8. Click Value twice to edit it. Type in the name of the login user that will be used to connect to the database.
    Figure 7. Enter the user name to be used for connections
    Enter the user name to be used for connections
  9. Repeat steps 6 through 8 to add PWD (password), Database, and ServerName to the data source. The entries are case-sensitive.
    Figure 8. All connection parameters specified
    All connection parameters specified
  10. Click OK, and then exit the ODBC Administrator application. The data source is ready to use.

Testing data source connectivity

If you have the iODBC SDK installed, you can use the OpenLink ODBC Administrator application to test your data source. Data sources created using the Apple ODBC Administrator will also appear. Follow these steps to test the data source:

  1. Highlight the data source to test.
  2. Click the Test button.
  3. Enter the database username and password. The OpenLink ODBC Administrator informs you whether the connection was successful.
Figure 9. Connection through OpenLink ODBC Administrator successful
Connection through OpenLink ODBC Administrator successful

Mac OS X comes with a command-line utility called iodbctest you can use to test ODBC drivers and data sources. The following set of steps describes how to use iodbctest to verify the DSN created above.

  1. Launch the Terminal application.
  2. Set the INFORMIXDIR, INFORMIXSQLHOSTS, ODBCINI, and DYLD_LIBRARY_PATH variables (if not already set). The commands for to use bash, ksh, and other Bourne-compatible shells are:
    export INFORMIXDIR=<substitute path to your Client SDK installation here>
    export INFORMIXSQLHOSTS=/etc/InformixODBC/sqlhosts
    export ODBCINI=/Library/ODBC/odbc.ini
    export DYLD_LIBRARY_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql

    To commands to use csh and other C-shell compatible shells are:

    setenv INFORMIXDIR <substitute path to your Client SDK installation here>
    setenv INFORMIXSQLHOSTS /etc/InformixODBC/sqlhosts
    setenv ODBCINI /Library/ODBC/odbc.ini
    setenv DYLD_LIBRARY_PATH $INFORMIXDIR/lib:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql
  3. Type iodbctest and press Enter.
  4. When asked for the DSN connection string, enter DSN=storedemo;UID=informix;PWD=<informix_password>;ServerName=demo_on, replacing <informix_password> with the actual password for the Informix user account. The UID, PWD, and ServerName parameters are optional. The driver version and an SQL prompt appear.
  5. Enter an SQL statement, such as select * from customer. The results are displayed, as shown in Figure 10.
    Figure 10. Output from iodbctest
    Output from iodbctest
  6. Type exit, and press Enter to close the connection and iodbctest.

Applied connectivity using FileMaker Pro and OpenOffice.org

In Part 2 of this series, you can see walkthroughs of Informix CSDK ODBC connectivity using FileMaker Pro and OpenOffice.org tools.


Conclusion

This article demonstrated how to use the new Mac OS X ODBC features available with Informix Client-SDK and Connect 3.50.xC3. Full integration with the native Apple ODBC framework makes connecting native Mac OS X applications to IBM Informix Dynamic Server as straightforward and simple as point-and-click.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Information management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=382687
ArticleTitle=Integrate Informix ODBC applications on Mac OS X with Informix Dynamic Server, Part 1: Installing and registering the ODBC bundle driver graphically
publish-date=04162009