This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Checking string" Watch "Checking string" New topic
Author

Checking string

sreeni san
Ranch Hand

Joined: Aug 14, 2001
Posts: 39
Hi
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)
x="y";
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.
Thanks
sreeni
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

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
Don't get me started about those stupid light bulbs.
 
subject: Checking string
 
Similar Threads
tag textfield: how to avoid blank values while displaying in jsp page
NULLs in ActionForm problem
data locking; competing actions
How to have checkbox value blank instead of "null"
Null or blank String into database