title: How to Convert Oracle Number(19) to Java Long?
body: <p><strong>How to Convert Oracle Number(19) to Java Long ?</strong> <br/><em>(Number(19) means equivalent to java Long as per this <a href="https://docs.oracle.com/cd/E19501-01/819-3659/gcmaz/" rel="nofollow">https://docs.oracle.com/cd/E19501-01/819-3659/gcmaz/</a>)</em> <br/></p>
  
  <p>I don't want to use Long.parseLong or Long.valeOf as both throws exceptions. <br/><br/>
  Here is my data in DB <br/></p>
  
  <pre><code> ColName (Foreign key, Nullable)
   1
   null
   100325
   null
  </code></pre>
  
  <p><br/>Here are the alternative I tried <br/>
  1)  <code>program.setXX(rs.getLong("colName"))</code>
  <br/> It returns values (1,0,100325,0). <em>null values are replaced with 0</em>
  <br/>2) <code>program.setXX((Long)rs.getObject("colName"));</code>
  <br/>3) <code>program.setXXX(Long.parseLong(rs.getString("colName")));</code>
  <br/>4) <code>program.setXXX(Long.valueOf(rs.getString("colName")));</code>
  <br/> These above 3 throws exception, And My POJO setter accept Long.</p>
  
  <p><br/>
  I am expecting result like <strong>(1,null,100325,null)</strong>, Whenever DB has null value , Java should  hold it, And Whenever DB has long value(non null) , Java should  hold it.<br/><br/></p>
  
  <p>I am doing this in spring JDBC template RowMapper, <br/>
  <strong>Is there any alternative for above steps?</strong> like Some Apache Utility method or Spring inbuilt method.<br/></p>