aspose file tools*
The moose likes JDBC and the fly likes Supressing Null column in a Result Set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Supressing Null column in a Result Set" Watch "Supressing Null column in a Result Set" New topic
Author

Supressing Null column in a Result Set

Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Hi All
How can we suppress a Null column in a reslutset? I mean, suppose a table has three columns and only two columns has data and the third column is entirely Null, when i fetch the resultset, i get this null column also. But while using this result set i have to suppress the empty column. How can this be done?
While fetching from resultset, how can i know whether the entire column is null?


SCJP 1.5
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
While fetching from resultset, how can i know whether the entire column is null?

You don't.
The only way you can find if this happens is to execute a sql command which ask this specific question.
Something like: select count(*) from t where c3 is not null.

Anyhow, why would you want to do this? Because you spent very few resources to get a column with null values.


http://javasign.blogspot.com/
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
This topic is usually discussed on the JDBC forum. Moving.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18129
    
    8

I don't understand what you mean when you say "suppress" a column. If you want to skip certain code if something you read from a ResultSet is null, then an if-statement would do. Or maybe you need an SQL solution like what Aurelian posted. But in any case you need to explain your problem more clearly.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Supressing Null column in a Result Set
 
Similar Threads
How do you check is Result set is null
retriving two primary keys
Get results from user defined query
How do you check is Result set is null
What is -Xlint in compiling java program?why this is done?