# RazorSQL

## Query, Edit, Browse, and Manage Databases

- razorsql.com
- Contact

# MySQL cannot convert value '0000-00-00 00:00:00' from Column x to TimeStamp

The MySQL Connector/J JDBC driver changed the way it handles DATETIME values in version 3.1. DATETIME values of all zeroes are considered illegal in versions 3.1 and above of MySQL Connector/J. Thus, an exception is thrown when these values are retrieved from a table.
Listed at the bottom of this message is an excerpt from the MySQL Connector/J manual that talks about this.
There is a way to override this behavior using Connector/J version 3.1.7 or higher. The override can be done by appending a property and value onto the JDBC URL.
In the connection profiles tab in RazorSQL, click "Edit" next to the JDBC URL and append the following to the end of the JDBC URL:
?noDatetimeStringSync=true
This will allow the all zeroes DATETIME values to be retrieved.
The following text is taken from the following link:
http://dev.mysql.com/doc/refman/5.0/en/connector-j-installing-upgrading.html
Datetimes with all-zero components (0000-00-00 ...) These values can not be represented reliably in Java. Connector/J 3.0.x always converted them to NULL when being read from a ResultSet. Connector/J 3.1 throws an exception by default when these values are encountered as this is the most correct behavior according to the JDBC and SQL standards. This behavior can be modified using the zeroDateTimeBehavior configuration property. The allowable values are:
exception (the default), which throws an SQLException with an SQLState of S1009.
convertToNull, which returns NULL instead of the date.
round, which rounds the date to the nearest closest value which is 0001-01-01.
Starting with Connector/J 3.1.7, ResultSet.getString() can be decoupled from this behavior via noDatetimeStringSync=true (the default value is false) so that you can get retrieve the unaltered all-zero value as a String. It should be noted that this also precludes using any time zone conversions, therefore the driver will not allow you to enable noDatetimeStringSync and useTimezone at the same time