Return-Path: Delivered-To: apmail-ibatis-dev-archive@www.apache.org Received: (qmail 84967 invoked from network); 20 Jun 2006 16:48:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jun 2006 16:48:55 -0000 Received: (qmail 99308 invoked by uid 500); 20 Jun 2006 16:48:54 -0000 Delivered-To: apmail-ibatis-dev-archive@ibatis.apache.org Received: (qmail 99171 invoked by uid 500); 20 Jun 2006 16:48:54 -0000 Mailing-List: contact dev-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ibatis.apache.org Delivered-To: mailing list dev@ibatis.apache.org Received: (qmail 99160 invoked by uid 99); 20 Jun 2006 16:48:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2006 09:48:54 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jun 2006 09:48:53 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 948F5410006 for ; Tue, 20 Jun 2006 16:47:30 +0000 (GMT) Message-ID: <23288178.1150822050605.JavaMail.jira@brutus> Date: Tue, 20 Jun 2006 16:47:30 +0000 (GMT+00:00) From: "Jeff Butler (JIRA)" To: dev@ibatis.apache.org Subject: [jira] Commented: (IBATIS-310) DateTypeHandler throws NullPointerException on null Timestamps for some drivers In-Reply-To: <20321236.1150820069847.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ 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