IBM AS/400 connectivity

From: Date: Fri, 20 Oct 2000 20:06:29 +0000
Subject: IBM AS/400 connectivity
Groups: php.db 
Request: Send a blank email to php-db+get-3833@lists.php.net to get a copy of this message
Hi, Has anyone tried connecting to PHP using IBM's db2 7.1 stuff that you can download? It's probably unlike that I'm asking in the right place, but if anyone here has had any luck connecting to an AS/400 DB2 database and using it under PHP on Linux, I'd very much like to talk to them about how they did it. I found the on php.faqts about installing and using it (reproduced as someone else on this list might like to see it too) .. Has anyone run into the problem that when you get to the 'connect' stage, it comes up with: SQL8002N DRDA connect processing failed; a valid product license was not found. SQLSTATE=42968 Is that something that's up with the AS/400 or the software I downloaded do you think? Any other suggestions to get it working? All help gratefully received. Derek ------ from php.faqts 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). -- Derek Piper - dpiper@stens.com - Stens Corporation

« previous php.db (#3833) next »