panchmp / sqlsheet

Automatically exported from code.google.com/p/sqlsheet
Other
27 stars 11 forks source link

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

Closed GoogleCodeExporter closed 2 months ago

GoogleCodeExporter commented 9 years ago
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 dennisl...@gmail.com on 23 Jul 2014 at 11:26

GoogleCodeExporter commented 9 years ago
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 dennisl...@gmail.com on 23 Jul 2014 at 11:37

manticore-projects commented 2 months ago

This has been solved quite a while ago.