[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Checking SQL  null  values

Posted on 2004-11-20
5
Medium Priority
?
189 Views
Last Modified: 2010-03-31
Frds,
  I getting values from database , I m concating these value and passing back in bean,
       If in database value is null I want to Pass "Not specified"  ..
   How can I compare SQL  null..?
I did this ..
String tCityId ="Not specified";
  if(rs.getString(8)!=null){
            tCityId             =rs.getString(1);
}
How to do this?

0
Comment
Question by:Manish
5 Comments
 
LVL 13

Accepted Solution

by:
petmagdy earned 90 total points
ID: 12633517
String dbValue = rs.getString(8);
tCityId = (dbValue == null)?"Not specified":dbValue;
0
 
LVL 3

Expert Comment

by:vikraman_b
ID: 12633707
String dbValue = rs.getString(8);
String tCityId = "";
if(dbValue == null)
tCityId = "Not Specified";
else
tCityId = dbValue;

0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12633720
vikraman_b,
same result as mine but more code
0
 
LVL 92

Assisted Solution

by:objects
objects earned 60 total points
ID: 12640395
String tCityId = rs.getString(8);
if (rs.wasNull()) tCityId = "Not Specified";
0
 
LVL 11

Author Comment

by:Manish
ID: 12671908
  As null value is string stored in database..
I did this..
   tCityId.equals("null);
Any way thanks...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question