Execute SQL remotely on an IBM i via PHP’s PDO ODBC from a Windows or Linux

You’ll first have to configure an ODBC connection “System DSN”/”System Data Source” via the “iSeries Access ODBC driver” or it might be call the IBM i Access driver which you can get here:

Windows: http://www-03.ibm.com/systems/power/software/i/access/windows.html
Linux: http://www-03.ibm.com/systems/power/software/i/access/linux.html

You’ll also find an installation guide on those IBM pages

Here’s some of the ways to configure the odbc connection


Once you have the ODBC connection setup you can use it in PHP and here’s a Simple Example on how to execute SQL remotely and safely on an IBM i via ODBC.  Note you won’t want to dump the error info in production its there to alert you about errors.

Here’s an example on how to run a SQL extenal stored procedure


Make sure to enable SSL to encrypt your SQL statements that are sent



Run C:\Windows\SysWOW64\odbcad32.exe and edit connection options and make sure ssl is selected or IBM i navigator is defaulted to sslodbc windows secure.png


Setup stunnel

guide is here: under 2.6 Encrypt the connection with Secure Sockets Layer

IBM i Debugging Networking issues

This is just a starting article.  I plan to add more ways of debugging networking issues as I learn more:

5250 Commands for debugging networking on the IBM i

QSYS/PING RMTSYS(example.com)

or you could download Perzl binaries and run various AIX/Unix tools for networking.

NetCat http://www.perzl.org/aix/index.php?n=main.netcat
Nmap http://www.perzl.org/aix/index.php?n=main.nmap

openssl s_client -connect example.com:443

wget http://www.oss4aix.org/download/RPMS/netcat/netcat-1.10-2.aix5.1.ppc.rpm
rpm –ignoreos –ignorearch –nodeps –replacepkgs -hUv netcat-1.10-2.aix5.1.ppc.rpm

group system does not exist - using root
netcat                      ##################################################
Listen on a server socket :
$ netcat -l -p 45678
In a new terminal session connect to the local server socket from client
$ netcat 45678

Send a message to the server

$ netcat 45678 
Hello Server this is the client
On the server we should see :
$ netcat -l 45678
Hello Server this is the client

ctrl+c twice to break out of the connection

OSI Networking Layers

JDBC JT400 setting to get CrUD and Show SQL features added in Netbeans with IBM DB2 for i

I finally figured out the missing connection property needed so that Netbeans will allow you to add, edit, and delete rows with inline editors and selected rows.  In addition to showing SQL Scripts for Create,Insert,Delete and Update.  It is the extended metadata property which is by default set to false and needs to be set to true.  I found this out by looking the jdbc properties at http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/rzahh/jdbcproperties.htm and looking for properties effecting read only status, which is why those features were blocked on Netbeans.

In your connection properties add

extended metadata=true

by right clicking your connection in the database panel of netbeans while disconnected and going to properties

Screen Shot 2016-08-21 at 5.45.29 PM.png

Click the ellipses …) next to connection properties
Screen Shot 2016-08-21 at 5.45.53 PM.png

Click under the property column and type extended metadata.  Click under Value and type true

Screen Shot 2016-08-21 at 5.46.28 PM.png

Now run a SELECT statement and you’ll be able to Create, Update and Delete records by using the icons above the result set or by right clicking the result set area and using the context menu.  Which also had the Show SQL Scripts for CrUD.

Screen Shot 2016-08-21 at 5.28.59 PM.png

DB2 for i in the Cloud – Connecting to PUB400 via JDBC in Netbeans

1.Sign up for an account at http://pub400.com/signup.html

2. Download and extract jtopen which contains lib/jt400.jar driver for connecting to an IBM i http://jt400.sourceforge.net/

3. Download and install Netbeans https://netbeans.org/ .  I do the PHP bundle, but i believe they all have the Database module.

4. Go into the “services” tab under database and right click the Drivers folder and click “New Driver”Screen Shot 2016-08-20 at 7.30.57 PM.png

Find where you extracted JT400 and select lib/jt400.jar

Screen Shot 2016-08-20 at 7.32.19 PM.png

Press the “Find” button so it can find the AS400JDBCDriver class in the jar file and give the driver a name like “JT400 JDBC Driver”

Screen Shot 2016-08-20 at 7.34.55 PM.png

Right click the driver and click “connect using” Screen Shot 2016-08-20 at 7.36.33 PM.png

Fill out the connection wizard with your information given to you from PUB400.com

User Name: <Your username for PUB400>
Password: <Your password for PUB400>
JDBC URL: jdbc:as400://pub400.com/{replace curly bracket and this with your schema name}

Screen Shot 2016-08-20 at 7.09.37 PM.png

After clicking next, Select your Schema

Screen Shot 2016-08-20 at 7.10.21 PM.png

Give the connection a name

Screen Shot 2016-08-20 at 7.10.38 PM.png

Now you can connect to the DB2 for i in the cloud by right clicking the connection and pressing connect

Screen Shot 2016-08-20 at 7.46.26 PM.png

Now you have an easy to get to database connection to a sandbox DB2 for i!  Time to play with the temporal table support and other new enhancements for DB2!

Screen Shot 2016-08-20 at 7.48.05 PM.png

After connecting, your connection properties should show what settings are being used on the connection and even what version of the DB2.  In this case the server is on V7R2m0 :

Screen Shot 2016-08-20 at 7.13.29 PM.png

Step2 add CrUD features by modifying the connection property




Whats happening in #IBMiOSS today!

Here’s what’s cooking in the OSS world of IBM i.

Relic Package Manager for RPG

The Relic Package Manager for RPG is being worked on at https://github.com/Club-Seiden/RelicPackageManager by Liam. He’s planning to have a website similar to https://packagist.org/ for RPG packages. Please get the word out about the Relic package manager as its only useful if people are collaborating and using it to share their code like others are in the OSS world. There’s documentation on it at https://github.com/Club-Seiden/RelicPackageManager/wiki.

We’re two groups the IBM i OSS in ILE, and OSS in IBM i PASE/AIX

The ILE group are RPG / CL / Cobol etc… programmers who want to dive into sharing their code like the rest of languages do (PHP, Ruby, Python on github).  The PASE/AIX group are programmers versed in Linux like environments who want OSS tools written in C/C++ for unix systems and we want these tools on our IBM i.  Michael Perzl has a lot of these tools compiled and for use at http://www.perzl.org/aix/ , but we can’t rely on one man to compile all these tools so there’s developers who are looking into using GCC compiler to compile their own OSS programs from source on IBM i AIX/PASE.  Which requires much knowledge of the PowerPC, GCC compiler, AIX, RPM,etc…

Aggregating IBMiOSS content and finding this information

People are wondering how best to get and aggregate content. Might be time to brush up on your google searching skills https://www.google.com/advanced_search or get active in Ryver https://ibmioss.ryver.com/ or the gitter channel https://gitter.im/Club-Seiden/IBMiOSS_Public . Which offer daily asynchronous chat and conversations. I recommended content be aggregated in blogs, as I’ve found Alan Seiden and Chris Hird’s blogs to be very helpful in the past.

Compiling PHP 7 on IBM i from source

I’ve created an article on how to compile PHP 7 on I.  I have to thank the many people on  the Gitter channel that helped me accomplish this.  You can find out how to compile PHP 7 on i  here: https://godzillai5.wordpress.com/2016/06/21/compiling-php7-from-source-on-ibmi-pase-aix/

Inviting people who are brand new to IBM i OSS

People need to be educated in this new world of Git and OSS. A Git/OSS 101 class for people who are brand new to the concepts.  For learning Git this website was recommended https://try.github.io/levels/1/challenges/1 . I recommended Maybe someone should do a intro to contributing to Open Source RPG at Common next year? Intro to Github, Intro to Relic, etc…

Watch-out for Liam’s YouTube series on setting up Git on their IBM i!