faqts : Computers : Programming : Languages : PHP : Database Backed Sites : ODBC

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

108 of 115 people (94%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

AS/400
Connection from a Linux Box to AS/400 DB2
Connection from a Linux Box to IBM DB2 Mainframes

Sep 21st, 2000 10:04
Remo Ronchitelli,


The connection from a Linux Web Server
   equipped with Apache and PHP 4 
   to an IBM AS/400 (OS400 and DB2/400)
   system is possible and works fine.
   The same connection works with IBM
   mainframes equipped with OS/390,
   MVS/ESA, VM/ESA, VSE/ESA and IBM DB2.
   The only strict requirement is the
   version of OS400 operating system:
   it must be V4R2 with native TCP/IP
   support.
   The following is the hierarchical
   list of Software Layers used in the test.
   ++Linux RedHat 6.1 
   ------(Korn Shell pdksh rpm package required)
   ++Apache Web Server 1.3.12
   ++PHP 4.0.2 statically linked to Apache
   ------ with-ibm-db2 option enabled
   ++IBM DB2Connect Personal Edition for Linux
   ------ V7.1 free from somewhere in ibm.com
   The IBM DB2 UDB DB2Connect Personal Edition
   installation is performed via Korn shell script
   "db2setup". Use all the features you can select,
   and installl:
   DB2 Administration Client
   DB2 Connect Personal Edition
   Db2 Application Development Client
   The DB2 instance created on Linux is:
   "db2inst1" and password "ibmdb2" (defaulted).
   After this you can install PHP 4
   --with-ibm-db2 option enabled.
   You get some weak compilation warnings
   but don't worry (it would be better they missed).
   For PHP it looks exactly like you had
   installed IBM DB2 UDB Personal Edition
   (the whole DB2 engine "without" DB2Connect).
   On the AS/400 side you have to start
   "drda" tcp servers at port "446" (defaulted).
   On the AS/400 side you need also
   authorized userid and password.
   Along with IBM DB2Connect you get full
   HTML documentation (useful and clear).
   Now return to Linux:
   login as "db2inst1" password "ibmdb2" and
   type: "db2" (DB2 command line processor).
   This is the necessary to inform DB2Connect
   about the reality of DB2400 DataBase on the
   AS/400. Thatis:
   1. 'catalog tcpip node YOUR_FREE_NODE_NAME
      remote TCP_IP_ADDRESS_OF_AS400
      server 446
      remote_instance AS400_SYSTEM_NAME
      system YOUR_FREE_SYSTEM_NAME
      ostype OS400'
      (446 is the default port number of drda server)
      (ostype must be "OS400") 
   2. 'catalog dcs database YOUR_DB_NAME 
      as DB2400_REAL_NAME'
      (DB400_REAL_NAME is the cataloged name of
       DB2 system in the AS/400 or the RDBNAME of AS/400)
   3. 'catalog database YOUR_DB_NAME as PHP_DB_NAME
      at node YOUR_FREE_NODE_NAME
      authentication DCS'
      (if you choose authentication "SERVER" it doesn't work).
   4. 'connect to PHP_DB_NAME
      user AS400_USERID
      using AS400_PASSWORD'
   5. (Caution to escape double quotes!) 
      'bind \"/usr/IBMdb2/V7.1/bnd/@ddcs400.lst 
            BLOCKING ALL SQLERROR CONTINUE
            MESSAGES DDCS400.MGS GRANT PUBLIC\" '  
   6. 'connect reset'
   7. 'terminate'
     (quit from DB2 Command Line Processor).
   You can now access DB2/400 from a PHP script
   enabled with:
   'putenv
("LD_LIBRARY_PATH=/home/db2inst1/sqqlib/lib:$LD_LIBRARY_PATH"); ' 
   'putenv ("DB2INSTANCE=db2inst1"); ' 
   'odbc_connect(PHP_DB_NAME, AS400_USERID, AS400_PASSWORD);'
   Warning: The Table name referenced in your PHP script
   must be qualified with the "collection" or "library" name
   of AS/400 DB2 system. Example:
   "SELECT * FROM AS400LIB.TABLE"
   The default would be 
   "SELECT * FROM DB2INST1.TABLE" (surely wrong).
   Take your fun with AS/400 or Mainframe system!
   Remo Ronchitelli
   sangiorgionet@netscape.net