4.3 Deploying C/C++ applications

C and C++ are probably two of the most popular and well-known programming languages. They are general purpose programming languages developed in the 1970’s. The prevalence of these two languages still continues today on almost all operating systems even though Java and other languages have achieved great success.

DB2 provides various sets of APIs for C/C++ programmer for their choices. For users who are focusing on application development and accessing a DB2 database from applications, CLI and ODBC provide the programming interfaces and use dynamic SQL statements as function arguments.

Another option is embedded SQL. It takes the advantages of both static and dynamic SQL statements to access the database. Embedded SQL statements are placed in the host programming languages and therefore an additional procedure called precompilation is required. Precompilation transforms the embedded SQL statements into the host language function calls which are recognizable codes for the host language compiler. Not only C and C++, but also COBOL, FORTRAN, and REXX are supported host languages for the embedded programming.

There are other tasks which are critical for DB2 maintenance or administration, such as instance start and stop, runstats and reorg, and so on. To perform these administrative tasks against DB2, users can issue commands from CLP, invoke SQL routines, or use DB2 Administrative APIs. DB2 Administrative APIs, also known as DB2 APIs, are a set of callable interfaces that give the customer an easy way to administer DB2 from a programming language. It could be used together with either CLI and ODBC, or embedded SQL.

4.3.1 CLI and ODBC

In this section, we discuss an approach to bundle an application and the IBM Data Server Driver for ODBC and CLI in a single package. This package can then be a deployed to other systems. The operating system that our procedure is based upon is either Linux or UNIX.

Before getting to the sample application and deployment script, we first discuss some background and considerations for CLI and ODBC applications.

DB2 Call Level Interface (DB2 CLI) is IBM’s callable SQL interface to the DB2 family of database servers. It is a C and C++ programming interface. DB2 CLI is based on the Microsoft Open Database Connectivity (ODBC) specification and the International Standard for SQL/CLI. These specifications are the basis for

154DB2 Deployment Guide

Page 168
Image 168
IBM manual Deploying C/C++ applications, CLI and Odbc, 154 DB2 Deployment Guide