title: In Java DB2 JDBC: How can one use null parameters in a WHERE clause for a SELECT statement where the value can be either null or not null?
body: <p>For example I have the following select query for a PreparedStatement:</p>
  
  <p>"SELECT FOO FROM BAR WHERE FOOBAR=?"</p>
  
  <p>The parameter for FOOBAR can have a value and it could also be null.</p>
  
  <p>Would the following code work?</p>
  
  <pre><code>if(&lt;condition&gt;) preparedStatement.setString(1, "&lt;string value&gt;");
  else preparedStatement.setString(1, null);
  </code></pre>
  
  <p>If not, how should this be handled?</p>