inserting missing values
What is the best way to handle missing values. For example, suppose I have an array that I want to insert into a table, like double[] row = {1.0, 2.0, MISSING, 4.0} where MISSING indicates a value that is missing. (I realize this is not a valid double value). I have been using a prepared statement to set a null value anytime I have missing data like, pstmt.setNull(i+1, Types.DOUBLE); However, the problem is that using rs.getDouble(3) returns a value of zero instead of null. The problem is that zero is a legitimate double value, not a missing or null value. Is it better to inset data using Double.NAN like pstmt.setDouble(i+1, Double.NaN);? What is the best way to handle missing data? Thanks
Re: inserting missing values
You need to check using wasNull method whether the value is null. See jdbc javadocs for ResultSet class. On Dec 14, 2010 8:46 PM, Patrick Meyer meyer...@gmail.com wrote: What is the best way to handle missing values. For example, suppose I have an array that I want to insert into a table, like double[] row = {1.0, 2.0, MISSING, 4.0} where MISSING indicates a value that is missing. (I realize this is not a valid double value). I have been using a prepared statement to set a null value anytime I have missing data like, pstmt.setNull(i+1, Types.DOUBLE); However, the problem is that using rs.getDouble(3) returns a value of zero instead of null. The problem is that zero is a legitimate double value, not a missing or null value. Is it better to inset data using Double.NAN like pstmt.setDouble(i+1, Double.NaN);? What is the best way to handle missing data? Thanks
Re: inserting missing values
Aha! That's just what I needed. Thank you! On Tue, Dec 14, 2010 at 3:05 PM, Peter Ondruška peter.ondru...@gmail.comwrote: You need to check using wasNull method whether the value is null. See jdbc javadocs for ResultSet class. On Dec 14, 2010 8:46 PM, Patrick Meyer meyer...@gmail.com wrote: What is the best way to handle missing values. For example, suppose I have an array that I want to insert into a table, like double[] row = {1.0, 2.0, MISSING, 4.0} where MISSING indicates a value that is missing. (I realize this is not a valid double value). I have been using a prepared statement to set a null value anytime I have missing data like, pstmt.setNull(i+1, Types.DOUBLE); However, the problem is that using rs.getDouble(3) returns a value of zero instead of null. The problem is that zero is a legitimate double value, not a missing or null value. Is it better to inset data using Double.NAN like pstmt.setDouble(i+1, Double.NaN);? What is the best way to handle missing data? Thanks