[ http://issues.apache.org/jira/browse/IBATIS-310?page=comments#action_12416935 ]
Jeff Butler commented on IBATIS-310: ------------------------------------ iBATIS is behaving according to the spec. I think the driver is acting wierd because of the date format. If the physical file has '0001-01-01' in the column, then it is NOT a null - it is a special value. So wasNull() should be false - and the value returned from getTimestamp() should be a valid date. The problem is likely that your date format is "mdy", and that the special value is invalid for "mdy" format. Try this again an add ";date format=iso" to the connection URL. I'm betting that will solve the problem (the expected behavior is that you will get a non-null value back with the date set to '0001-01-01'). > 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