[ http://issues.apache.org/jira/browse/IBATIS-310?page=all ] Jeff Butler closed IBATIS-310: ------------------------------
Resolution: Invalid Not a bug - as explained in the comments. > DateTypeHandler throws NullPointerException on null Timestamps for some > drivers > ------------------------------------------------------------------------------- > > Key: IBATIS-310 > URL: http://issues.apache.org/jira/browse/IBATIS-310 > Project: iBatis for Java > Type: Bug > Components: SQL Maps > Versions: 2.1.6 > Environment: JDBC Driver: JT Open driver for AS/400 (tested 4.8, 4.9, and > 5.1.1) > Reporter: Matt DeHoust > > The problem is in DateTypeHandler in the getResult method. > java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnName); > if (rs.wasNull()) { > return null; > } else { > return new java.util.Date(sqlTimestamp.getTime()); > } > In our case, the JDBC driver is returning null, but wasNull() returns false > because the database value is not null. The AS/400 uses a special low value > ('0001-01-01') to represent null dates and timestamps. > Since Timestamp is an object, the recommended fix is to simply check for null > rather than using wasNull as follows. > java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnName); > if (sqlTimestamp == null) { > return null; > } else { > return new java.util.Date(sqlTimestamp.getTime()); > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira