Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    4

    Unanswered: JDBC - calling DB2 Stored Procedure

    DB2 Stored Procedure accepts one input parameter as "int". How to pass value "null" from java using JDBC to this input parameter?

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: JDBC - calling DB2 Stored Procedure

    From the command line I use 'null' when calling :

    db2 "call db2admin.sample(?,null)"

    I think you can either do as above or have a variable set to null and use that variable to call the procedure

    HTH

    Sathyaram

    Originally posted by vijaydpatil
    DB2 Stored Procedure accepts one input parameter as "int". How to pass value "null" from java using JDBC to this input parameter?
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Dec 2002
    Posts
    134

    Re: JDBC - calling DB2 Stored Procedure

    Something like below:

    Connection con = ...
    PreparedStatement stmt = con.prepareStatement("call schema.sp(?)");
    stmt.setNull(1, Types.INTEGER);
    stmt.execute();

  4. #4
    Join Date
    Sep 2003
    Posts
    4
    Thats true. I am calling it from java. I do: callableStatement.setInt(4,...). Here I cannot assign either null/null object because null cannot be assigned to java primitive integer datatype.
    looking for solution....

  5. #5
    Join Date
    Dec 2002
    Posts
    134
    Originally posted by vijaydpatil
    Thats true. I am calling it from java. I do: callableStatement.setInt(4,...). Here I cannot assign either null/null object because null cannot be assigned to java primitive integer datatype.
    looking for solution....
    check documentation for the setNull method:
    callableStatement.setNull(4, Types.INTEGER);

  6. #6
    Join Date
    Sep 2003
    Posts
    4
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •