Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:34:07+00:00 2026-06-11T21:34:07+00:00

I am calling a stored procedure from my Java application and getting the following

  • 0

I am calling a stored procedure from my Java application and getting the following error while setting the input parameter.

1: Java method for calling the procedure:

public int callProc(String userid, String program_id, String procName)
        throws SQLException {

    int returnCode = -1;

    try {

        CallableStatement stmt;

        String sql = "CALL " + procName + "(?,?,?,?,?)";
        stmt = connection.prepareCall(sql);

        System.out.println("Calling stored procedure [" + procName + "]");

        // call setXXX() method to set values for input parameters
        // and input-output parameters
        System.out.println("jdbcadapter->callproc setting 1 parameter "+stmt);
        stmt.setObject(1, userid, java.sql.Types.CHAR);
        System.out.println("jdbcadapter->callproc setting 2 parameter "+sql);
        stmt.setObject(2, program_id, java.sql.Types.CHAR);
        System.out.println("jdbcadapter->callproc setting 3 parameter "+sql);
        stmt.setObject(3, session_id, java.sql.Types.CHAR);
        System.out.println("jdbcadapter->callproc setting 4 parameter "+sql);
        stmt.setObject(4, " ", java.sql.Types.CHAR);
        System.out.println("jdbcadapter->callproc setting 5 parameter "+sql);
        stmt.setObject(5, " ", java.sql.Types.CHAR);
        System.out.println("jdbcadapter->callproc setting 6 parameter "+sql);
        // call registerOutParameter() method to define the data types for output parameters
        stmt.registerOutParameter(4, java.sql.Types.CHAR); // rc
        System.out.println("jdbcadapter->callproc setting 7 parameter "+sql);
        stmt.registerOutParameter(5, java.sql.Types.CHAR); // result message
        System.out.println("jdbcadapter->callproc setting 8 parameter "+sql);

        stmt.execute();
        System.out.println("jdbcadapter->callproc after execute "+sql);

        String rc = stmt.getString(4);
        System.out.println("jdbcadapter->callproc after execute "+rc);
        String message = stmt.getString(5);
        System.out.println("jdbcadapter->callproc after execute "+message);
        Integer return_code = new Integer(rc.trim());
        System.out.println("jdbcadapter->callproc after execute "+return_code);
        returnCode = return_code.intValue();
        System.out.println("jdbcadapter->callproc after execute "+returnCode);
        return_message = message.trim();
        System.out.println("jdbcadapter->callproc after execute "+return_message);
        System.out.println("Returned code from stored procedure is ["+ rc.trim() + "]");
        stmt.close();

    } catch (Exception e) {
        throw ((SQLException) e);
    }

    return returnCode;

} // end callProc()

The problem is occuring while setting the USER ID in the stmt at

stmt.setObject(1, userid, java.sql.Types.CHAR);

Definition of Stored procedure on database side

CREATE PROCEDURE "CDR     "."SPUBASE"
                (
                IN      USERID   CHARACTER(12),
                IN      PROGRAM_ID   CHARACTER(20),
                IN      SESSION_ID   CHARACTER(27),
                OUT     SQLCODE   CHARACTER(254),
                OUT     SQLMESSAGE   CHARACTER(254)
                )
                DYNAMIC RESULT SETS 0
                SPECIFIC SQL040816123726847
                EXTERNAL NAME '/cdrtst/sqllib/function/SPUBASE!SPUBASE'
                LANGUAGE C
                PARAMETER STYLE DB2DARI
                NOT DETERMINISTIC
                FENCED NOT THREADSAFE
                MODIFIES SQL DATA
                NO DBINFO;

and the error is

SQLException: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=SPUBASE;PROCEDURE, DRIVER=4.1.85 

Could anyone suggest what can cause this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:34:08+00:00Added an answer on June 11, 2026 at 9:34 pm

    From this page explaining the reasons for SQLCODE: -440, one of the reasons is

    The right number of arguments was included in the routine reference, but the data type of one or more of the arguments is incorrect.

    I suspect that your following method call

    stmt.setObject(1, userid, java.sql.Types.CHAR);
    

    should be replaced with

    stmt.setString(1, userid);
    

    or

    stmt.setObject(1, userid, java.sql.Types.VARCHAR);
    

    I would prefer the former, i.e. setString and leave it to the driver to do the appropriate conversion based on the underlying DB/column.

    The same would apply to other statement.set* methods as well, calling the appropriate set* method like setString, setInt etc.,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting the following error when calling a stored procedure: Cannot find the object
HI I am getting this exception when I am calling any stored procedure from
I'm currently calling a stored procedure from a .net application that inserts records into
Actually I am calling oracle procedure from java file present at application server. I
I'm getting the error below when calling a simple SP from the Rational Application
We have a winforms application calling a stored procedure every few seconds. The stored
In Ado.net, the code is calling a stored procedure with input and output parameters.
When calling a stored procedure from vb.net is there a default SQL timeout time
I have a java program that is calling a MySQL stored procedure that is
I'm calling a stored procedure from C# .net and one of the string parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.