Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if name.equals("") doesn't work :[

 
Katia Platonov
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I am stumped
I want to build a column header if anything returned from it from the database and ignore it if it's empty.
I've tried:
if((rs.getString("name").equals(""))
{
out.println("dont' build headers")
}
else
{
out.println("build headers")
}
but it's completely ignoring the logic and builds headers every time.
In my database when I run this query:
select * from user_info where name != ''
users with filled in name column displayed
When I run:
select * from user_info where name = ''
all the rest are displayed.
I do not understand where the problem lies.
Would anybody please help?
Thank you very much.
Katya.
 
prabhat kumar
Ranch Hand
Posts: 114
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the column "name" is isnull field
then use this
if((rs.getString("name")!=null)
{
out.println("build headers");
}
else
{
out.println("dont' build headers");
}
 
Katia Platonov
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for replying. You see... this is the problem...
The columns that are empty do not have NULL values.
They look like they have spaces and my query that checks for spaces works, yet name.equals("") doesn't work.
With your solution it will never build headers because those columns are never NULL.
And that is where I'm stumped.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

Rene
 
Katia Platonov
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked!!!
Thank you so so so very much.
Katya.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic