Detect null value in database

How to detect null value in a database field and how to handle the error? Whenever I use a getDate() method to access a blank date field, there will be error in the console and no response in the program.
[218 byte] By [hanxue] at [2007-9-26 2:36:38]
# 1
When getting the value from the result set you can use wasNull() to check whether the last read value was null or not and do appropriate handlingHope this helps,Ramkumar
SRamkuma at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...
# 2
try to use nvl function in the query itself and replace any null date with some string.like select nvl(date,'Null') from table name.
b_babu at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...
# 3
Is that function database specific?I mean, can it be used with ANY type of database?
hanxue at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...
# 4
most of the RDBMS having that function,i have used for oracle,sql server. what DB u are using? Try to execute the query in sql mode and then replace in ur code
b_babu at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...
# 5
I have not checked it out. By the way, I am using Access since I am experimenting with JDBC.
hanxue at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...
# 6
i don't think access will support nvl function,any way check it out
b_babu at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...
# 7

Hi,

At the jdk 1.3 docs you can see : getDate() returns null

if the column is SQL null so you can test if your var refers

null before use it :

some_date=rs.getDate(1);

if(some_date == null) -> do some action

else -> proceed norm

The sol via funct. nvl is dependend of Database (ex. in Oracle Rdb not exist) and I think is a "bad solution"

Bye

yomismo at 2007-6-29 10:04:42 > top of Java-index,Archived Forums,Swing...