| Bug #13486 | ResultSet.getString() or getDate() returns SQL Exception with 0000-00-00 dates | ||
|---|---|---|---|
| Submitted: | 26 Sep 2005 14:22 | Modified: | 26 Sep 2005 15:47 |
| Reporter: | William Vicente | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 3.1.7 | OS: | Windows (Win2000) |
| Assigned to: | CPU Architecture: | Any | |
[26 Sep 2005 15:47]
Mark Matthews
This behavior is as-intended. See the following section in the docs: http://dev.mysql.com/doc/mysql/en/cj-upgrading.html#cj-upgrading-3-0-to-3-1

Description: The Connector returns an SQLException when trying to read a DATETIME field in Mysql with a '0000-00-00 00:00:00' value. java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Date at com.mysql.jdbc.ResultSet.getDateFromString(ResultSet.java:4648) at com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1023) at com.mysql.jdbc.ResultSet.getDate(ResultSet.java:980) at com.mysql.jdbc.ResultSet.getDate(ResultSet.java:994) at MyClass.run(MyClass.java:426) How to repeat: Fill a DATETIME field with it value set to '0000-00-00 00:00:00' and try to use the ResultSet.getString or getDate methods to retrieve this field value.