• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I replce NULL with "" Nothing at all??

 
rastas biggs
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a recordset pulling from my database

I using rs.getString("somevalue") I using the PrintWriter

in the out.print(); etc..

Now aas you can see below using the getString method if there is not data in my database it returns null, rather than using a bunch of if statements what can I use to replace null with "" nothing at all so


|soemval|null|someval - becomes - |soemval||someval

2222222222|False|Residential|Private|1|Y|||Mr|Rastas|Biggs||3/3/1901||22222222|33333333|null|Mobile|N
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably an if statement:

 
rastas biggs
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I thought so god damnit! thanks for the reply
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bunch of static utility methods for String. One of them is called nullAsEmpty. It does something like:

Instead of repeating an if null test for every field, I can just print Util.nullAsEmpty(field). I hate to copy any code over and over for every field!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!