Apple Enterprise - NeXTanswers Support Archive

Search NeXTanswers for:

Title: DB2 EOF Adaptor example
Procedure Valid for Release: EOF 2.1

Keywords: EOF, OPENSTEP, WebObjects, Enterprise Objects

....Why It Works
....Creating the DB2 Adaptor
....Using the DB2 Adaptor
....More information


This script modifies the ODBC adaptor example source code so that it can access DB2 databases. Building the modified adaptor requires IBM's DB2 CLI SDK; running it requires the DB2 CLI client libraries. Contact IBM directly for more information on these products, or visit their web page at

This script was written using EOF 2.1 installed on Windows NT and Solaris, and tested with DB2 version 2.1.2 and with a beta copy of version 5. It is provided as-is, and is not supported on any platform.

Why It Works

Because the ODBC and DB2 API's are both based on the CLI specification, they are roughly source code compatible. This script allows you to recompile the ODBC adaptor against the DB2 CLI headers; a simple name change allows it to coexist with the ODBC adaptor. The new adaptor classes will be identical to the classes discussed in the ODBC adaptor class documentation.
Creating the DB2 Adaptor

+ Download the script from

+ The ODBC adaptor source code example is not installed by the Solaris default installation. If you want to compile under Solaris, you will need to copy these files from an NT machine.

+ Modify the script if necessary. The ODBCDIR variable controls where the script will look for the ODBC example (the default is /NextDeveloper/Examples/EnterpriseObjects/ODBCAdaptor). The DB2DIR variable controls where the script will write the new DB2 example; the default is /NextDeveloper/Examples/EnterpriseObjects/DB2Adaptor).

+ Run the script. On Solaris, from a terminal shell, cd to the appropriate directory and type "./odbc2db2". On NT, use the command "sh odbc2db2".

+ Using ProjectBuilder or a text editor, open the Makefile.preamble-winnt or Makefile.preamble-solaris file appropriate to your build platform. Set the value of the DB2_DIR variable to the location of your DB2 SDK (the default values are C:/SQLLIB for NT and /opt/IBMdb2/V2.1 for Solaris).

+ If you are installing under Windows NT, set the install directory using ProjectBuilder's project inspector panel. On Unix, change the INSTALLDIR variable in the project's Makefile.

+ Build and install the framework. On NT, use ProjectBuilder's project panel; on Unix, cd to the project directory and type "make". You will see compilet warnings during the compilation process; ignore them.

Using the DB2 Adaptor

DB2 databases have a two level naming scheme consisting of a schema and a table. When creating a new model, the default entity names will be a concatenation of schema name and table name. The default schema name is the user's name. To modify that, specify the schema name in the connection string; i.e, use a connection string of the form DSN=dbname,UID=username,PWD=password,SCHEMALIST=schemaname. Optional keywords may also be specified in the DB2CLI.INI file.

More information

This script is provided as-is and is not supported by Apple Enterprise Software. For more information on using DB2, visit IBM's DB2 web page at

OpenStep | Alliances | Training | Tech Support | Where to Buy