aspose file tools*
The moose likes JDBC and the fly likes how to set a null and how to retrieve it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to set a null and how to retrieve it" Watch "how to set a null and how to retrieve it" New topic
Author

how to set a null and how to retrieve it

ramchander yshetti
Ranch Hand

Joined: Apr 22, 2006
Posts: 97
hai,
how to set a null values into a table and
how to retrieve the null values from the table

i used the methods
setNull() and getNull() i am not getting
please solve my query with example..

thank Q

bye.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2503
    
    8

To set null values:
PreparedStatement.setNull().

To check null values: ResultSet.wasNull().

Regards, Jan
[ April 24, 2007: Message edited by: Jan Cumps ]

OCUP UML fundamental and ITIL foundation
youtube channel
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410


To check null values: ResultSet.wasNull().


ResultSet's wasNull only checks if last column read was Null
Better and scalable approach is always to write a utility class for checking null value and check the value returned against it
e.g. You wrote Util.java and one of the methods is
boolean isNull(Object obj)

then simply use it and you will know if the value returned is Null or not
[ April 24, 2007: Message edited by: Gaurav Chikara ]

SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set a null and how to retrieve it