This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I need to insert null in NUMBER field which is nullable