+ All Categories
Home > Documents > 2.4a Informix Application Development Survey Lab

2.4a Informix Application Development Survey Lab

Date post: 02-Jun-2018
Category:
Upload: fundacionfenixtech
View: 216 times
Download: 0 times
Share this document with a friend

of 31

Transcript
  • 8/10/2019 2.4a Informix Application Development Survey Lab

    1/31

    IBM Informix 11.5

    InformixApplicationDevelopment andExtensibility

    Choose one of the following labs:

    Connecting to Informix Databases Using JDBC, ODBC, ESQL/C andPHP

    Java Application Development

    Informix 4GL

    The Basic Text Search (BTS) DataBlade

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    2/31

    2

    Information Management Partner Technologies

    IBM Informix 11.5

    Connecting to InformixDatabases Using JDBC,ODBC, ESQL/C and PHP

    I

    Information Management Partner Technologies

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    3/31

    3

    Contents

    1. INTRODUCTION ...........................................................................................4 2. SUGGESTED READING...............................................................................4

    3. CONNECTING TO AN INFORMIX DATABASE USING THE IBM DATASERVER DRIVER FOR JDBC .............................................................................5

    3.1 WHAT IS JDBC?.......................................................................................5 3.2 WHAT IS A JDBC DRIVER ?.........................................................................6 3.3 WHAT ARE DIFFERENT TYPES OF JDBC DRIVERS ?.......................................6 3.4 JDBC DRIVERS FOR INFORMIX ...................................................................7 3.5 S TARTING INFORMIX ..................................................................................8 3.6 INSTALLING THE IBM D ATA S ERVER DRIVER FOR JDBC AND SQLJ ..............9 3.7 RUNNING A SAMPLE J AVA PROGRAM TO TEST THE CONNECTIVITY ................11

    4. CONNECTING TO AN INFORMIX DATABASE USING THE IBMINFORMIX ODBC DRIVER ................................................................................14

    4.1 WHAT IS ODBC?....................................................................................14 4.2 WHAT IS THE IBM INFORMIX ODBC DRIVER ? ............................................14 4.3 ODBC COMPONENT OVERVIEW ................................................................15 4.4 INSTALLING THE IBM INFORMIX ODBC DRIVER ..........................................16 4.5 RUNNING A SAMPLE C PROGRAM TO CHECK THE CONNECTIVITY ..................19

    5. PROGRAMMING WITH INFORMIX ESQL/C..............................................20

    5.1 WHAT IS INFORMIX ESQL/C? ..................................................................20 5.2 HOW CAN YOU CREATE AN ESQL/C PROGRAM ? ........................................20 5.3 INSTALLING THE IBM INFORMIX ESQL/C DRIVER ......................................21 5.4 RUNNING A S AMPLE ESQL/C P ROGRAM TO TEST THE CONNECTIVITY ........23

    6. CONFIGURING PHP ENVIRONMENT FOR INFORMIX DATABASES .....24

    6.1 WHAT IS PHP?.......................................................................................24 6.2 INFORMIX INTERFACES FOR PHP..............................................................24 6.3 S ETTING UP THE PHP APPLICATION ENVIRONMENT FOR INFORMIX ...............26 6.4 RUNNING A SAMPLE PROGRAM TO CHECK THE PHP CONFIGURATION ...........29 6.5 RUNNING A SAMPLE PHP PROGRAM TO TEST THE INFORMIX D ATABASE

    CONNECTIVITY ......................................................................................29

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    4/31

    4

    1. Introduction

    This lab describes how to install, configure and use JDBC, ODBC,ESQL/C and PDO drivers to connect to Informix databases from Java,C, ESQL/C, and PHP applications respectively. This lab is especiallyuseful for database administrators who are asked to support manydifferent development environments.

    2. Suggested Reading

    IBM Informix Dynamic Server 11.5 Information CenterThis is the official online searchable Informix product documentation.

    http://publib.boulder.ibm.com/infocenter/idshelp/v115/index.jsp

    IBM Data Server Driver for JDBC and SQLJ for Informix guide

    This publication describes how to use the IBM Data Server Driver forJDBC and SQLJ, which allows you to write client applications that canconnect to DB2 and Informix data servers.

    www.ibm.com/support/docview.wss?uid=swg27010058

    IBM Informix ODBC Driver Programmers Manual

    This manual is a user guide and reference manual for IBM InformixODBC Driver, which is the Informix implementation of the MicrosoftOpen Database Connectivity (ODBC) interface, Version 3.0. Thismanual explains how to use the IBM Informix ODBC Driver applicationprogramming interface (API) to access an Informix database andinteract with an Informix database server.

    www.ibm.com/support/docview.wss?uid=swg27013893

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    5/31

    5

    IBM Informix ESQL/C Programmer's Manual

    This manual describes the features that make up the IBM Informiximplementation of embedded SQL for C.

    www.ibm.com/support/docview.wss?uid=swg27013893

    Developing PHP Applications for IBM Data Servers

    This IBM Redbook contains comprehensive information about how todevelop and deploy Web solutions using PHP and IBM Data Servers,including Informix.

    www.redbooks.ibm.com/abstracts/sg247218.html

    A step-by-step how-to guide to install, configure, and test aLinux, Apache, Informix, and PHP server

    This developerWorks article shows how to install, configure, and test aLinux, Apache, Informix, and PHP (LAIP) server. LAIP provides a verypowerful and dynamic mixture for a Web server.at the following link.

    www.ibm.com/developerworks/db2/library/techarticle/dm-0606bombardier

    3. Connecting to an Informix Database Usingthe IBM Data Server Driver for JDBC

    3.1 What is JDBC?Java database connectivity (JDBC) is the Java specification of astandard application programming interface (API) that allows Javaprograms to access database management systems. The JDBC APIconsists of a set of interfaces and classes written in the Javaprogramming language.

    Using these standard interfaces and classes, programmers can writeJava applications that connect to databases, send queries written instructured query language (SQL), and process the results.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    6/31

    6

    3.2 What is a JDBC driver?The JDBC API defines the Java interfaces and classes thatprogrammers use to connect to databases and send queries. A JDBC

    driver implements these interfaces and classes for a particular DBMSvendor.

    3.3 What are different types of JDBC drivers?There are four types of JDBC drivers:

    JDBC-ODBC bridge plus ODBC driver, also called Type 1driver

    o Translates JDBC API calls into Microsoft ODBC callsthat are then passed to the ODBC driver.

    o The ODBC binary code must be loaded on every clientcomputer that uses this type of driver.

    o ODBC is an acronym for Open Database Connectivity.

    Native-API, partly Java driver, also called Type 2 driver

    o Converts JDBC API calls into DBMS-specific client APIcalls.

    o Like the bridge driver, this type of driver requires thatsome binary code be loaded on each client computer.

    JDBC-Net, pure-Java driver, also called Type 3 driver

    o Sends JDBC API calls to a middle-tier server thattranslates the calls into the DBMS-specific networkprotocol.

    o The translated calls are then sent to a particular DBMS.

    Native-protocol, pure-Java driver, also called Type 4 driver

    o Converts JDBC API calls directly into the DBMS-specificnetwork protocol without a middle tier.

    o This allows the client applications to connect directly tothe database server.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    7/31

    7

    3.4 JDBC drivers for InformixFor Informix, there are two drivers that implement the JDBCspecification:

    Informix JDBC Driver

    IBM Data Server Driver for JDBC and SQLJ, also called JavaCommon Client (JCC)

    The Informix JDBC Driver uses the Informix proprietary SQLI protocolwhereas the IBM Data Server Driver uses the Distributed RelationalDatabase Architecture (DRDA) protocol.

    In this lab you will use the IBM Data Server Driver for JDBC and SQLJas that is the preferred driver for new Java applications.

    The IBM Data Server Driver for JDBC and SQLJ is also integratedwith DB2. This capability means that the common features of thedriverallow you to write client applications that can use both DB2 andInformix data servers.

    The IBM Data Server Driver for JDBC and SQLJ is compliant with theSun Microsystems JDBC 3.0 and JDBC 4.0 specifications.

    The following table should serve as an overview of features that mightimpact your decision on which driver to use (as of IBM Data ServerDriver Version 3.53).

    I n f o r m i x J D B C

    Dr ive r

    IBM Da ta Se rve r

    Dr ive r

    DRDA Connections X

    SQLI Connections X

    Informix version < 11.10 X

    JDBC 4.0 Functionality X

    INTERVAL,opaque- and user-defined data types, collection data types

    X

    Automatic client reroute (failover) X

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    8/31

    8

    Note: This table is not a complete list of differences. For moreinformation see:

    http://publib.boulder.ibm.com/infocenter/idshelp/v115/topic/com.ibm.jccids.doc/com.ibm.db2.luw.apdv.java.doc/doc/r0052865.htm

    3.5 Starting Informix Although it is not required to start the Informix instance beforeinstalling the JDBC driver, you will need the Informix database to beup and running in order for the sample Java program to work.

    Follow the steps below to start the Informix instance:

    Login into the VMWare image as the informix user.

    Note: Refer to the document entitled VMWare Basics forinformation about how to start and login to the VMWare Image.

    Right click on the desktop area and choose Open Terminal .

    Set the environment for the database server by typing thefollowing commands in the command terminal.

    cd scripts

    . setDemo

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    9/31

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    10/31

    10

    Extract the zip file into an empty directory.

    The zip file contains the following files:

    * db2jcc.jar * db2jcc4.jar

    * sqlj.zip * sqlj4.zip

    Important: For this lab, the JDBC driver files have already beendownloaded and extracted for you.

    Important : the CLASSPATH variable has already been set.

    Normally you would have to modify the CLASSPATHenvironment variable to include the appropriate files:

    For JDBC, include db2jcc.jar in the CLASSPATH if you plan touse the version of the IBM Data Server Driver for JDBC andSQLJ that includes only JDBC 3.0 and earlier functions.

    Include db2jcc4 .jar in the CLASSPATH if you plan to use theversion of the IBM Data Server Driver for JDBC and SQLJ thatincludes JDBC 4.0 and later functions, as well as JDBC 3.0 andearlier functions.

    Important: Include db2jcc.jar or db2jcc4.jar in theCLASSPATH . Do NOT include both files.

    Enter the following command at the command prompt to verifythe CLASSPATH (it should contain db2jcc.jar) :

    echo $CLASSPATH

    Configure a new server alias in the SQLHOSTS file for thedrsoctcp connection protocol.

    Important: There is already an entry for the Informix server inthe SQLHOSTS file. You can verify this by locating theSQLHOSTS file and looking at its contents.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    11/31

    11

    Enter the following command at the command prompt to locatethe SQLHOSTS file used by the instance.

    echo $INFORMIXSQLHOSTS

    This displays the name and the location of the SQLHOSTS file.

    Look at the contents of the file:

    cat /opt/IBM/informix/etc/sqlhosts.demos

    You should see a drsoctcp entry for the demo_on server withthe name demo_ondrda . It is listening for connections on portnumber 9089.

    3.7 Running a sample Java program to test theconnectivityWe have provided a sample Java program that can be used to test theconnection to an Informix database using the IBM Data Server Driverfor JDBC.

    Using a text editor, enter and save the following lines of code ina file called Connect2IDS.java in the/home/informix/scripts/java directory.

    Important: This file is available to you in the/home/informix/scripts/java directory. You do NOTneed to type the code below.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    12/31

    12

    // Program to test connection to an Informix dB using JCCdriver

    import java.util.*;

    import java.sql.*;public class Connect2IDS {

    public static void main( String[] args) throws SQLException,ClassNotFoundException {

    Connection conn;

    PreparedStatement pstmt;

    ResultSet rs;

    String URL = "jdbc:ids://ids1150srvr:9089/stores";

    String user = "informix";

    String password = "informix";

    String driverClass = "com.ibm.db2.jcc.DB2Driver";

    Class.forName( driverClass );

    conn = DriverManager.getConnection(URL, user, password);

    if (conn != null) {

    System.out.println("Got a connection to the DB");

    String [] tableTypes = { "TABLE", "VIEW" };

    DatabaseMetaData dbmd = conn.getMetaData();

    rs = dbmd.getTables(null, null, null, tableTypes);

    while (true == rs.next()) {

    System.out.println( rs.getString(2) + "." +rs.getString(3) + " [" + rs.getString(4) + "]");

    }

    conn.close();

    }

    return;

    }

    }

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    13/31

    13

    Compile the java program using the following commands:

    cd /home/informix/scripts/java

    javac Connect2IDS.java

    A file with the name Connect2IDS.class will be generated aftersuccessfully compiling the program.

    Run the Java program after successful compilation:

    java Connect2IDS

    After successful execution, the program will output the list oftables in the STORES database.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    14/31

    14

    4. Connecting to an Informix Database Usingthe IBM Informix ODBC Driver

    4.1 What is ODBC?Open Database Connectivity (ODBC) is a specification for a database

    Application Programming Interface (API). Microsoft ODBC, Version3.0, is based on the Call Level Interface specifications from X/Openand the International Standards Organization/InternationalElectromechanical Commission (ISO/IEC). ODBC supports SQLstatements with a library of C functions. An application calls thesefunctions to implement ODBC functionality.

    4.2 What is the IBM Informix ODBC driver?The IBM Informix ODBC Driver implements the Microsoft OpenDatabase Connectivity (ODBC) Version 3.0 standard.

    IBM Informix ODBC applications enable you to perform the followingoperations:

    1. Connect to and disconnect from data sources

    2. Retrieve information about data sources

    3. Retrieve information about the ODBC Driver

    4. Set and retrieve ODBC Driver options

    5. Prepare and send SQL statements

    6. Retrieve SQL results and process the results dynamically

    7. Retrieve information about SQL results and process theinformation dynamically

    ODBC lets you allocate storage for results before or after the results

    are available. This feature lets you determine the results and theaction to take without the limitations that predefined data structuresimpose. ODBC does not require a pre-processor to compile anapplication program.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    15/31

    15

    4.3 ODBC component overviewODBC with the IBM Informix ODBC Driver can include the followingcomponents:

    Driver manager

    An application can link to a driver manager, which links to the driverspecified by the data source. The driver manager also checksparameters and transitions. On most UNIX platforms, the ODBCDriver Manager can be purchased from a third-party vendor. The DataDirect ODBC driver manager is shipped with the CSDK bundle for SunSolaris 32-bit and IBM AIX 32-bit platforms. On Microsoft Windowsplatforms, the ODBC Driver Manager is a part of the OS.

    IBM Informix ODBC Driver

    The driver provides an interface to an Informix database server. Applications can use the driver in the following configurations:

    To link to the ODBC driver manager

    To link to the Driver Manager Replacement and the driver

    To link to the driver directly

    Data sources

    The driver provides access to the following data sources:

    Database management systems (DBMS), including a databaseserver.

    Databases

    Operating systems and network software for accessing thedatabase.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    16/31

    16

    4.4 Installing the IBM Informix ODBC driver The IBM Informix ODBC Driver is installed as part of the

    installation of the Informix Client Software Development Kit

    (CSDK). The CSDK has already been installed as part of theInformix installation on the VM image used in this exercise. Formore information about how to install CSDK, refer to theInformix Information Center.

    Set the following environment variables:

    INFORMIXDIR: Full path to the directory where CSDK isinstalled. On the VM Image, it is same as the Informix ServerInstallation directory.

    PATH: Make sure $INFORMIXDIR/bin is included in the$PATH

    INFORMIXSQLHOSTS: Name of the SQLHOSTS file with fullpath.

    Important : All of these environment variables have alreadybeen set for you.

    Login to the VM image as the informix user and verify thecurrent values of these variables using the following commands:

    echo $INFORMIXDIR

    echo $PATH

    echo $INFORMIXSQLHOSTS

    Copy the file $INFORMIXDIR/etc/odbcinst.ini to yourhome directory.

    cp $INFORMIXDIR/etc/odbcinst.ini ~

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    17/31

    17

    Using a text editor such as vi, edit the ~/odbcinst.ini file:

    In the section [IBM Informix ODBC Driver]:

    i) Update the Driver and Setup lines to include the correct path

    Driver=/opt/IBM/informix/lib/cli/iclit09b.so

    Setup=/opt/IBM/informix/lib/cli/iclit09b.so

    ii) Save and exit.

    Copy the file $INFORMIXDIR/etc/odbc.ini to your homedirectory.

    cp $INFORMIXDIR/etc/odbc.ini ~

    Set the environment variable ODBCINIexport ODBCINI=$HOME/odbc.ini

    Edit the $HOME/odbc.ini file.

    i) Update the Driver field to/opt/IBM/informix/lib/cli/iclit09b.so

    ii) Update the Database field to stores

    iii) Update LogonID field to informix

    iv) Update the pwd field to informix

    v) Update the Servername field to demo_on

    vi) Update the TRANSLATIONDLL field to/opt/IBM/informix/lib/esql/igo4a304.so

    vii) Update the InstallDir field to /opt/IBM/informix/

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    18/31

    18

    vii) Save and exit.

    Create or edit the $HOME/.netrc file to make an entry on theserver for the informix user.

    The format of the line that you need to add looks like thefollowing:

    machine login informix password

    where:

    machinename is host name or IP address of the server

    password is the password of the informix user

    Open the .netrc file available in the informix home directoryand add the following line and save the file:

    machine ids1150srvr login informix password informix

    Edit the SQLHOSTS file and make an entry for the onsoctcpprotocol for the database instance.

    The format of the line that needs to be added is as follows: onsoctcp

    where:

    dbservername is the name of the Informix server.

    machinename is the name or IP address of the host

    portnumber is the number of the port..

    Note: The following entry has already made for you in the$INFORMIXDIR/etc/sqlhosts.demos file. You do NOT have to make any modifications to the sqlhosts file.

    demo_on onsoctcp *localhost 9088

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    19/31

    19

    Set the environment variable LD_LIBRARY_PATH. Enter thefollowing command at the command prompt.

    exportLD_LIBRARY_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql

    You have now completed the basic installation and configuration ofthe Informix ODBC driver.

    4.5 Running a sample C program to check theconnectivity

    Locate and examine the catalog.c sample program. Thisprogram retrieves information from the system catalogs.

    cd $INFORMIXDIR/demo/cli/

    cat catalog.c

    Compile the program

    make catalog

    Execute the program.

    ./catalog Infdrv1

    Note: Infdrv1 is the DSN name from the $ODBCINI file.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    20/31

    20

    5. Programming with Informix ESQL/C

    5.1 What is Informix ESQL/C?ESQL/C is an SQL application programming interface (API) thatenables you to embed Structured Query Language (SQL) statementsdirectly into a C program. The ESQL/C preprocessor, which the esql command invokes, converts each SQL statement and all Informix-specific code to C.

    5.2 How can you create an ESQL/C program?You create an Informix ESQL/C program using the following steps:

    Embed Informix ESQL/C statements in a C-language sourceprogram that perform the following tasks:

    o Define host variables to store data for transfer betweenthe Informix ESQL/C program and the database server.

    o Access the database server through SQL statements.

    o Provide directives for the Informix ESQL/C preprocessorand the C compiler.

    Preprocess the Informix ESQL/C source file with the esql command to create a C-language source file and invoke the Ccompiler.

    As necessary, correct errors reported by the preprocessor andthe compiler and repeat step 2.

    Using the esql command, link the compiled object code intoone or more executable files.

    An Informix ESQL/C source file may contain the following types ofstatements:

    Preprocessor directives

    Informix ESQL/C preprocessor directives are used to createsimple macro definitions, include Informix ESQL/C files, andperform conditional Informix ESQL/C compilation.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    21/31

    21

    C preprocessor directives are used to create macro definitions,include system and C source files, and perform conditional Ccompilation.

    Language statements

    Informix ESQL/C host variable definitions store data for transferbetween the Informix ESQL/C program and the databaseserver.

    Embedded SQL statements communicate with the databaseserver.

    C language statements provide program logic.

    5.3 Installing the IBM Informix ESQL/C Driver The IBM Informix ESQL/C driver is installed as part of the

    installation of the Informix Client SDK (CSDK). CSDK is alreadyinstalled on the VM image used in this lab. For moreinformation about installing the CSDK, refer to the InformixInformation Center.

    Set the following environment variables:

    INFORMIXDIR: Full path to the directory where CSDK isinstalled. On the VM Image it is same as the Informix serverinstallation directory.

    PATH: Make sure $INFORMIXDIR/bin is included in the$PATH

    INFORMIXSQLHOSTS: Name of the SQLHOSTS file with fullpath.

    We have already set all these environment variables for you.You can login to VM Image as the informix user and verify thecurrent values of these variables using the followingcommands:

    echo $INFORMIXDIR

    echo $PATH

    echo $INFORMIXSQLHOSTS

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    22/31

    22

    Create or edit the $HOME/.netrc file to make an entry on theserver for the informix user.

    The format of the line that you need to add looks like thefollowing:

    machine login informix password

    where:

    machinename is host name or IP address of the server

    password is the password of the informix user

    Open the .netrc file in the informix users home directory, addthe following line, and then save the file.

    machine ids1150srvr login informix password informix

    Edit the SQLHOSTS file and make an entry for the onsoctcp protocol for the database instance.

    The format of the line that needs to be added is as following:

    onsoctcp

    where:

    dbservername is the name of the Informix Server.

    machinename is the name or IP address of the host

    portnumber is the number of the port. An entry in /etc/servicesfile.

    Note: The following entry has already made for you in the$INFORMIXDIR/etc/sqlhosts.demos file. You do NOT have to make any modifications to the sqlhosts file.

    demo_on onsoctcp *localhost 9088

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    23/31

    23

    Set the environment variable LD_LIBRARY_PATH

    Enter the following command at the command prompt.

    export

    LD_LIBRARY_PATH=$INFORMIXDIR/lib:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql

    We are done with the basic installation and configuration of theInformix ODBC driver.

    5.4 Running a Sample ESQL/C Program to Test theConnectivityThere are plenty of demo programs in the/opt/IBM/informix/demo/esqlc directory on the VM image.

    Open the demo1.ec program in a text editor and change thename of the database to stores :

    EXEC SQL connect to stores;

    Can you figure out what this simple program does?

    Compile the demo1.ec program and create an executable file:

    esql demo1.ec -o demo1

    Run the demo1 executable file that is created in the previousstep:

    ./demo1

    If the program is executed successfully, you will see all outputrows displayed on the screen.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    24/31

    24

    6. Configuring PHP Environment for InformixDatabases

    6.1 What is PHP?PHP is one of the world's most popular programming languages forbuilding dynamic data-driven Web applications. The PHP code can bea standalone program as well as embedded inside HTML (HypertextMarkup Language) or XHTML (Extensible Hypertext MarkupLanguage).

    6.2 Informix interfaces for PHP

    Since PHP Version 3, Informix databases have served PHP clientapplications via the Informix connectivity software (Informix CSDK orInformix Connect). PHP applications could connect to the Informixdatabase server using either the native embedded SQL interface orwith the invocation of an ODBC library using the CLI (call levelinterface).

    The following are the three most popular PHP APIs for Informix:

    PDO

    PDO Core is written in C for increased performance

    Simple to learn ( Only 2 classes )

    o PDO Connection

    o PDOStatement Statement

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    25/31

    25

    PDO_INFORMIX

    A PDO based extension for Informix

    Written in C entirely by IBMers

    Supported on PHP 5.1 and greater

    Requirements:

    o The Informix Client Software Development Kit (CSDK)

    Available at: pecl.php.net/package/PDO_INFORMIX

    PDO_IBM

    A PDO based extension for IBM data servers

    Written in C entirely by IBMers

    Common PHP driver using the DRDA protocol, supportingInformix, DB2, Apache Derby.

    Supported on PHP 5.1 and greater

    Requirements:

    o IBM Data Server Client for compilation/runtime

    o DRDA configuration Available at: pecl.php.net/package/PDO_IBM

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    26/31

    26

    6.3 Setting up the PHP application environment forInformixImportant: For step-by-step information about installing, configuring,and testing a Linux, Apache, Informix, and PHP server, refer to thefollowing article on the developerWorks Web site:

    www.ibm.com/developerworks/db2/library/techarticle/dm-0606bombardier

    This section provides an overview of the steps involved in manuallysetting up a PHP application development environment for Informix.

    Important : All these steps have already performed on the VM Image. Also note that a PHP environment is set up if you use the OpenAdminTool!

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    27/31

    27

    A prerequisite for setting up the PHP environment is the setupof the Informix Server and CSDK.

    Download and unpack the source code for the Apache HTTPServer, PHP, and Informix PHP Data Objects (PDO) driver.

    Install and configure Apache HTTP Server

    o The steps below outline how to install Apache withsupport for dynamically loaded modules:

    (This assumes that the Apache source files are storedat: /usr/local/src/httpd-2.2.0 )

    cd /usr/local/src/httpd-2.2.0./configure \

    --prefix=/usr/local/apache \

    --enable-shared=max \

    --enable-module=rewrite \

    --enable-module=so

    make

    make install

    Install and configure PHP

    A PHP installation requiers :

    o An ANSI C compiler

    o flex : Version 2.5.4

    o bison : 1.28, 1.35, or 1.75

    o A web server

    o Any module-specific components

    o Building PHP extensions on UNIX requires the phpize utility

    o PHP 4 is not object oriented and doesnt support PDO

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    28/31

    28

    Most Linux distributions come with PHP already installed.Manual compilation from source requires an ANSI Ccompiler.

    buildconf force

    ./configure (--help)

    make

    make install

    Installation of PDO_INFORMIX / PDO_IBM

    There are two options here:

    o Build with the PHP source

    o Build stand alone

    phpize (inside the extension source directory)

    ./configure with-pdo-ibm=/home/db2inst1/sqllib

    ./configure with-pdo-informix=/opt/informix

    make

    make install

    Installation Debugging

    o Check to make sure the IBM Data Server client andInformix CSDK is installed correctly.

    o Make sure that the buildconf utility is run after copyingthe source directory to the ext directory.

    o Make sure the options in the configure script arecorrect.

    o Make sure the PHP version and extension version are

    the same.o Make sure the PHP release/debug type are the same as

    the extensions.

    o Make sure the correct php.ini file is being loaded.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    29/31

    29

    6.4 Running a sample program to check the PHPconfiguration

    In a text editor of your choice, enter and save the followingthree lines of code in a file called phpinfo.php in the/home/informix/scripts/php directory:

    In the terminal windows set the paths for the php interpreterand the necessary libraries:

    export PATH=$PATH:/opt/IBM/OpenAdmin/PHP_5.2.4/bin

    exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/IBM/OpenAdmin/PHP_5.2.4/lib

    Open a terminal window, and run the program with the followingcommand

    php /home/informix/scripts/php/phpinfo.php

    The About program will display the PHP configuration details onthe screen. Examine the output.

    6.5 Running a sample PHP program to test theInformix Database Connectivity

    There is a sample PHP program called connect2IDS.php available in the /home/informix/scripts/php directory.

    Run the program using the following command.

    php -c /opt/IBM/OpenAdmin/PHP_5.2.4/lib/php.iniconnect2IDS.php

    If you are interested, open the file in a text editor and examinethe code to see how it works.

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    30/31

  • 8/10/2019 2.4a Informix Application Development Survey Lab

    31/31

    Copyright IBM Corporation 2010 All Rights Reserved.

    IBM Canada8200 Warden AvenueMarkham, ONL6G 1C7Canada

    Printed in Canada01/2010

    IBM, IBM (logo), and Informix are t rademarks or registeredtrademarks of International Business Machines Corporation in theUnited States, other countries, or both.

    Linux is a trademark of Linus Torvalds in the United States, other

    countries, or both

    UNIX is a registered trademark of The Open Group in the UnitedStates, other countries, or both

    Windows is a trademark of Microsoft Corporation in the UnitedStates, other countries, or both.

    Other company, product, or service names may be trademarks orservice marks of others.

    References in this publication to IBM products or services do notimply that IBM intends to make them available in all countries inwhich IBM operates. The following paragraph does not apply to theUnited Kingdom or any other country where such provisions areinconsistent with local law:

    INTERNATIONAL BUSINESS MACHINES CORPORATIONPROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY

    OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR APARTICULAR PURPOSE.

    Some states do not allow disclaimer of express or impliedwarranties in certain transactions, therefore, this statement may notapply to you.

    This information could include technical inaccuracies ortypographical errors. Changes are periodically made to theinformation herein; these changes will be incorporated in neweditions of the publication. IBM may make improvements and/orchanges in the product(s) and/or the program(s) described in thispublication at any time without notice.

    Any performance data contained herein was determined in acontrolled environment. Therefore, the results obtained in otheroperating environments may vary significantly. Some

    measurements may have been made on development-levelsystems and there is no guarantee that these measurements will bethe same on generally available systems. Furthermore, somemeasurement may have been estimated through extrapolation.

    Actual results may vary. Users of this document should verify theapplicable data for their specific environment.

    Information concerning non-IBM products was obtained from thesuppliers of those products, t heir published announcements orother publicly available sources. IBM has not tested those productsand cannot confirm the accuracy of performance, compatibility orany other claims related to non-IBM products. Questions on the

    capabilities of non-IBM products should be addressed to thesuppliers of those products.

    The information in this publication is provided AS IS withoutwarranty. Such information was obtained from publicly availablesources, is current as of January 2010, and is subject to change.

    Any performance data included in the paper was obtained in thespecific operating environment and is provided as an illustration.Performance in other operating environments may vary. Morespecific information about the capabilities of products describedshould be obtained from the suppliers of those products.


Recommended