sqlsheet icon indicating copy to clipboard operation
sqlsheet copied to clipboard

ResultRset get<Number> throws NullPointerException if the cell is empty

Open GoogleCodeExporter opened this issue 10 years ago • 1 comments

Any empty cell  withResultSet.get<Number> methods (e.g. getInt(), getFloat(), 
...).

In JDBC with real database return zero value not throwing NullPointerException 
or return null value.

It seems it can be fixed by simplely check "cell.doubleValue == null" in 
get<Number> methods like this:

return (<type>) ((cell == null) ? 0.0D : cell.doubleValue.doubleValue());
  --> 
return (<type>) ((cell == null || cell.doubleValue == null) ? 0.0D : 
cell.doubleValue.doubleValue());

Original issue reported on code.google.com by [email protected] on 23 Jul 2014 at 11:26

GoogleCodeExporter avatar Mar 14 '15 03:03 GoogleCodeExporter

I just realize that the code in my previous comments not exactly same as in 
source code and here are updated code based on source code:

return (<type>) (cell == null ? 0 : cell.doubleValue);
-->
return (<type>) (cell == null || cell.doubleValue == null? 0 : 
cell.doubleValue);


Original comment by [email protected] on 23 Jul 2014 at 11:37

GoogleCodeExporter avatar Mar 14 '15 03:03 GoogleCodeExporter

This has been solved quite a while ago.

manticore-projects avatar Aug 24 '24 10:08 manticore-projects