• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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: 42165
937
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic