File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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: 39791
    
  28
This topic is usually discussed on the JDBC forum. Moving.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Supressing Null column in a Result Set