title: Proper way to handle null value for Oracle Date datatype in prepared statement
body: <p>I have a database with more than 20 columns and some of them are <code>date</code>/<code>timestamp</code> data types with null values. </p>
  
  <p>Java application will read the data from this table and insert into other table. Prepared Statement is used to frame insert query. When inserting the record, I get <em>"null pointer exception"</em> on date columns where ever it is null. For the <code>Varchar</code>, it is automatically setting to null when the actual value is null. Is there any way to handle the Date fields with null values automatically as like <code>varchar</code> in prepared statements?</p>
  
  <pre><code>PreparedStatement ps = null;
  ....
  ....
  ps.setDate(3, new java.sql.Date(date.getTime())); //date is Java.Util.Date
  </code></pre>
  
  <p>Getting Error. So I handle manually like below</p>
  
  <pre><code>if(date!= null)
      ps.setDate(3, new java.sql.Date(date.getTime()));
  else
      ps.setNull(3, Types.DATE);
  </code></pre>