• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to pass a NULL parameter in prepareCall method.

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai All

I have got a problem in invoking a stored procedure from java code,

The Java code is:
-----------------

cstmt = connection.prepareCall("{call INSERTUPSDEMO(?, ?, ?, ?, ?)}");

cstmt.setString(1, "SAM");
cstmt.setInt(2, 2000);
cstmt.setInt(3, 250);
cstmt.setInt(4, 3467);

cstmt.registerOutParameter (5, Types.INTEGER);
cstmt.execute();
temp = cstmt.getInt(5); // Get the output parameter values

My Problem:
-----------

The code works fine if i give all the parameters.
But in some cases i may not pass all the parameters,
for example if i dont want to send the parameter4 value,
i.e i want to send a null value into it.
I need to know how to pass a null parameter.


Any help is appreciated,
Thanks in advance,
Pooja
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pooja,
You need to call setNull(). Sun has a section in their tutorial on this.
 
Pooja Agarwal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Jeanne,

Thanks a lot for ur help.
It worked fine with setNull() method.

Thanks once again,
Pooja.
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic