Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Problem calling a stored procedure from a Java program

I have an external stored procedure written in SQL/RPG LE returning a result set. When I debug the program everything seems to work well. However, when I call the stored procedure from a Java program, while looping through the result set, exceptions are thrown. It looks like some of the fields are retuned as null values. While using a tool such as DbVisualizer and executing the stored procedure the result set displayed is a mixture of null and garbage values for most of the columns. I have created the stored procedure using the following statement:

               CREATE PROCEDURE P1 
              (IN PARM1 CHAR(7), 
               PARM2 CHAR(12)) 
               RESULT SETS 1 
               EXTERNAL NAME dcheri/SHIPBUILD 
                 PARAMETER STYLE SQL 
               LANGUAGE RPGLE; 
The external program was compiled as a module and then a program object was created using CRTPGM PGM(DCHERI/SHIPBUILD) ACTGRP(*CALLER). Please let me know what I am doing wrong.
Hard to say without seeing any of your procedure source code. Here are a couple of suggestions:

1. Apply the latest Database Group PTF on the server and make sure you have the latest fixes for the JDBC driver that you're using.

2. Try calling the stored procedure from the iSeries Navigator Run SQL Script window -- this interface will automatically display a window containing the contents of your result set. Java is used by iSeries Navigator to do this, so that can you help determine if it's a problem with your Java code.

3. Review your code to see if the parameter style specified is correctly implemented in your RPG code. The Redbook Stored Procedures, Triggers and User Defined Functions on DB2 Universal Database for iSeries is a good resource.

Dig Deeper on DB2 UDB (universal databases)

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.