Forums >> Programming >> Open Source >>
Running the Example Programs


Running the Example Programs

Running the Example Programs

The example programs listed at seemed to start of with "Hello World" and then from there continue on with very general, yet useful, examples.

Now, by "general" I mean just that.  The example has an input to enter an SQL statement (which the results of are returned as JSON) as well as a input to run a system command (not sure how safe that is...  yikes!)

First, I created a local IP address that I could use to run my node.js applications on (using CFGTCP option 1).  This IP address will be used in the applications to come.  The port number that is used is also specified in the node source so for this example I just chose to use a standard port of 80.

We also need a place that will hold the sample JS file and HTML file.  I decided to create a directory on my system named /nodejs that would be for all my node.js applications.  This of course should be easily changed if needed.  

I then created a subdirectory with my userid to hold my node.js source.  So, I had /nodejs/bvstone.  

Next I created the first node.js application from the sample and started up the application using Pase  (Pase is started using CALL QP2TERM.  I actually created a command named SSH that calls this to make it easier to remember).

node /nodejs/bvstone/sample.js           
Server running at 

Once up and running I opened my browser and pointed it to and low and behold, I saw "Hello World."

I then continued on through the examples and even got the SQL example to work.  But, when I started on the CL command example I started getting some errors.  I did some searching and found I could turn on more debugging for my application using the following on my connection:

var conn = new xt.iConn(DBname);

I then saw that I was getting the following error when trying to run a CL command:

CL statement : wrksyssts
[Error: SQLSTATE=57017 SQLCODE=-332 Character conversion between CCSID 1208 and CCSID 65535 not valid.]

If I ran it again I received a different error:

CL statement : WRKSYSSTS
[Error: SQLSTATE=HY010 SQLCODE=-99999 Error occurred in SQL Call Level Interface]  

I did a little digging and found that my user ID was set up to use *SYSVAL as the job CCSID.  The system value for QCCSID was 65535.  Well, that makes sense, I guess.  So I changed the system value for QCCSID to 37, signed off, signed back on, started my node job again and things were working great.

One important (and annoying) thing to remember is, if you make changes to your JavaScript code you will need to stop and restart your node instance to get the changes to load.  I only mention this because the instructions mentioned it only after the first change.  The next change it said to "refresh your web page" instead of restart your node instance.  Probably an oversight.  But, restarting each time seems a little tedious.  Maybe in this journey I'll find an answer or even a solution for this.

Next I will need to make my own example that works with real data to see how things really work in the real world.  That is what I'm most interested in.  No matter how much we hate to start with "Hello World" and other simple examples they are a necessary evil.


Last edited 03/27/2016 at 17:43:48


Copyright 1983-2017 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).