Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes I need to insert null in NUMBER field which is nullable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "I need to insert null in NUMBER field which is nullable" Watch "I need to insert null in NUMBER field which is nullable" New topic
Author

I need to insert null in NUMBER field which is nullable

lalitha prasad
Greenhorn

Joined: Aug 28, 2004
Posts: 16
Hi,

I need to do the following.

pst.setInt(1,null);

Is it possible?.

If anyone knows please help me.

thanks in advance,
LALITH
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
I guess the following might work.

PreapredStatement.setNull()

public void setNull(int parameterIndex, int sqlType) throws SQLException
Sets the designated parameter to SQL NULL.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Ed Wallen
Ranch Hand

Joined: Feb 11, 2002
Posts: 34
Call the setNull method on your prepared statement object (in your case, "pst") and pass it the appropriate type (in your case Types.INTEGER).


pst.setNull(index, Types.INTEGER);

-Ed
 
Don't get me started about those stupid light bulbs.
 
subject: I need to insert null in NUMBER field which is nullable
 
Similar Threads
Tag throwing null
How do I trim the null values from an array?
Values of Hash Map to be 2-dimensional array
extends LinkedList´╝îbut use iterator warning that is null
null pointer