title: Java PreparedStatement setting NULL parameters
body: <p>Java PreparedStatement allows you to set a value for a given parameter or to set it to NULL</p>
  
  <pre><code>SELECT *
  FROM ADDRESS
  WHERE ADDRESS_LINE1 = ? 
  </code></pre>
  
  <p>so we could write code to set this parameter:</p>
  
  <pre><code> if (addressLine1 != null) {
        preparedStatement.setString(1, addressLine1);
      } else {
        preparedStatement.setNull(1, VARCHAR);
      }
  </code></pre>
  
  <p>however it is also declared that you should never compare a value to null using the = operator and actually use the IS operator for null comparisons. </p>
  
  <p>Is the prepared statement actually swapping the = operator for IS under the covers here or is the null just being inserted still using the = operator? If the latter then when is it ever useful to use this and are you actually getting the expected outcome?</p>
  
  <p>I am asking this on the back of the following stack overflow question</p>
  
  <p><a href="https://stackoverflow.com/questions/9581745/sql-is-null-and-null">SQL is null and = null</a></p>