com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value

记录由Windows + MySql5.0.45 升级为Linux +Mysql 5.6.17时遇到的问题。

现象:数据库升级后,能正常查询。但在插入datetime类型的字段报如下错误:
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'crtTime' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2868)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)

解决方法:将驱动由mysql-connector-java-5.0.3-bin.jar更新为mysql-connector-java-5.1.10-bin.jar 问题解决。

你可能感兴趣的:(com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value)