 <pre><code>output = rs.getString("column");// if data is null `output` would be null, so there is no chance of NPE unless `rs` is `null` if(output == null){// if you fetched null value then initialize output with blank string output= ""; } </code></pre>