Use Hibernate to connect to the database of mysql5. Since the table uses a datetime time period, the following
Java. SQL. SQLException: Cannot convert value '2017-00-00 00:00:00 'from column 9 to TIMESTAMP.
At com. mysql. jdbc. ResultSet. getTimestampFromBytes (ResultSet. java: 6864)
At com. mysql. jdbc. ResultSet. getTimestampInternal (ResultSet. java: 6899)
At com. mysql. jdbc. ResultSet. getTimestamp (ResultSet. java: 6218)
At com. mysql. jdbc. ResultSet. getTimestamp (ResultSet. java: 6256)
At org. hibernate. type. TimestampType. get (TimestampType. java: 30)
At org. hibernate. type. NullableType. nullSafeGet (NullableType. java: 113)
At org. hibernate. type. NullableType. nullSafeGet (NullableType. java: 102)
The help document of mysql5 explains datetime as follows:
Datetimes with all-zero components (0000-00-00 ...) -These values can not be represented: for all data of the Datetime type consisting of 0, These values cannot be reliably expressed in java.
Reliably in Java.
Connector/J 3.0.x always converted them to null when being read from a resultset.
When these values are being read from the resultset container, connector/J 3.0.x always converts them to null values.
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.
According to JDBC and SQL standards, the most correct way to handle these values is to generate exceptions by default.
This behavior can be modified using the zerodatetimebehavior configuration property. The allowable values are:
JDBC allows the following values to be used to set these processing methods for the zerodatetimebehavior attribute,
Exception (the default), which throws an sqlexception with an sqlstate of s1009.
An exception (default) is thrown by an error number of the sqlstate, which is the same as the error number of the sqlstate.
Converttonull, which returns NULL instead of the date.
Set to converttonull. Use null to replace this date type.
Round, which rounds the date to the nearest closest value which is 0001-01-01.
If it is set to round, it is replaced by the closest value of this date (0001-01-01 ).
You can modify your JDBC connection
JDBC: mysql: // localhost/schoolmis? Useunicode = true & amp; characterencoding = utf8 & amp; zerodatetimebehavior = converttonull