• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how to pass a NULL parameter in prepareCall method.  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 38569
659
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hai Jeanne,

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

Thanks once again,
Pooja.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!