This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes initialization of variables type int as null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "initialization of variables type int as null" Watch "initialization of variables type int as null" New topic
Author

initialization of variables type int as null

Yanine Arellano
Greenhorn

Joined: Mar 14, 2007
Posts: 3
hi everyone, i have a store procedure in which one of the IN variables is an int and i have to send it as null, although whether i try this:
int count= null;
or
int count;
gives me error
How should i do it?

int count; --- this is where I initialize the variable and needs to be set as null.

CallableStatement ct = conn.prepareCall("{call fon.pck_mt3.db_mt3_deptran(?,?,?,?,?,?,?,?,?,?,?)}");

ct.setInt(1,count); // 1 count IN NUMBER, -- (15)

Thanks a lot, bye bye.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Try setNull().


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: initialization of variables type int as null
 
Similar Threads
SELECT COUNT
How to make combination function generic
Java Recursion and binary tree searching questions
Would like help about this excercise in HFJ
Database Metadata