title: JDBCTemplate optional parameters
body: <p>I am using spring JDBCTemplate.</p>
  
  <hr>
  
  <p>I have a scenario, where the parameters that need to be passed into my query function, are conditional/optional. For example, I have the following code:</p>
  
  <pre><code>List&lt;RealTimeDTO&gt; result = jdbcTemplate.query(sql, new Object[] {custId, 
  number, requestType, startDate, endDate}, new CCCRowMapper());
  </code></pre>
  
  <p>In the code, I passed in <code>custId, number, requestType, etc.</code> However, <code>requestType</code> is an optional parameter that may come back as <code>null</code> or <code>empty</code> so I don't want it to be passed into the <code>Object[]</code> if it is either <code>null</code> or <code>empty</code>. </p>
  
  <p>What can I do to handle this type of situation? </p>
  
  <p>I could introduce logic where I only pass in the parameters I want into the <code>Object[]</code>, however, I was wondering if there is an already built in functionality that handles this instead of me reinventing the wheel.</p>