It's not a secret anymore!
The moose likes Servlets and the fly likes Checking string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Checking string" Watch "Checking string" New topic

Checking string

sreeni san
Ranch Hand

Joined: Aug 14, 2001
Posts: 39
I retrieve data(String values of X column) from Database.
Data in database will be any of the three
a. "NULL"
b. some value
c. nothing(blank)
note: blank refers to empty not blank space

I need to set values based on the data(String) received like
If the value is not null
if(data!=null or when data is empty)
I am facing problems when data is empty. How will my if condition be?
It cannot be if (data.length==0) or if(data.equals("")) as when data will be "null", null pointer exception will be thrown
Kindly suggest a suitable soluton.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
There is a wasNull()method in the ResultSet interface. it indicates if the recently retrieved column is null


So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: Checking string
It's not a secret anymore!