[CONJ-100] the feature "Return null for 'zero' timestamps" while return a wrong result when call ResultSet.wasNull(). Created: 2014-05-13  Updated: 2014-11-26  Resolved: 2014-11-26

Status: Closed
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1.8

Type: Bug Priority: Major
Reporter: Han Yinghan Assignee: Massimo Siani (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Environment:

when we select a record from a table and the value of timestamp field is '0000-00-00 00:00:00', the result of this field is null, that's OK. but when we call wasNull(), is return false.



 Description   

test code :
public Object getResult(ResultSet rs, String columnName)
throws SQLException {
java.sql.Timestamp sqlTimestamp = rs.getTimestamp(columnName);
if (rs.wasNull())

{ return null; }

else

{ return new java.util.Date(sqlTimestamp.getTime()); }

}

when the value of the field 'columnName' is '0000-00-00 00:00:00', rs.wasNull() will return false, not true. it is wrong.



 Comments   
Comment by Han Yinghan [ 2014-05-13 ]

we solved this problem with following code:

AbstractValueObject.java

public boolean isNull()

{ return rawBytes == null || (dataType == MySQLType.TIMESTAMP && "0000-00-00 00:00:00".equals(getString()) ) ; }
Generated at Thu Feb 08 03:13:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.