Database Connectivity With Linux & PHP to IBM iSeries & DB2


I work with a local government, where the majority of our existing information systems are on an IBM iSeries machine.

The entire city runs on what is referred to as “green screen” apps. I was charged with the task of bringing our municipal utility company’s bill payment online. Well, not exactly bringing it online… but giving what is currently online a major overhaul.

The existing site was done with an abhorrent product called IBM WebSphere. Apparently people have made pretty impressive applications with this product, but I don’t see how. I spent three months in what I’ve dubbed “JSP hell” (while also working on other PHP/MySQL websites) trying to figure out what a Web Interaction is and then trying to figure out what COBOL program runs when a certain form is submitted. I’m not even going to start on COBOL.

Scattered throughout the JSP code were the one thing that made sense besides the HTML, SQL queries.

unix ODBC to the rescue

NOTE: This was all done on SUSE 10 Enterprise. Your mileage may very, blah blah blah, the usual disclaimer.

Per this wonderful, difficult to find IBM Redbook I found out that I need to install something called iSeries Access (IBM Account Required) – the software is in the form of a RPM.

[shell] rpm -ivh iSeriesAccess-5.2.0-X.YY.i386.rpm

We already had unixODBC installed.

After iSeries Access is installed, run this command:

[shell] odbcinst -j

You’ll get a path to some .ini files. Ours were in /etc/unixODBC/. Fire up your favorite text editor and edit /etc/unixODBC/odbc.ini.

Here is the sample config file that IBM references in the redbook. System is the IP or Domain name of the iSeries machine. Everything else is pretty self explanatory. Refer back to the redbook for clarification on a few of the settings if you need to.

After you’re done editing your file, verify that it works by running this command:

[shell] isql [Your DSN Name] [Your username] [Your Password]
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |

Now, you may need to reconfigure PHP to have unixODBC (use ./configure –with-unixODBC) . I didn’t.

After that, it’s simple: use odbc_connect() and you’re on your way.


2 Responses to Database Connectivity With Linux & PHP to IBM iSeries & DB2

  1. Pingback: Database Connectivity With Linux & PHP to IBM iSeries & DB2  »Technology News | Venture Capital, Startups, Silicon Valley, Web 2.0 Tech

  2. Josh says:

    Very nice. I may have to remember that sometime.

%d bloggers like this: