1、时区问题
往数据库插入datetime类型的时间发现,数据库里存储的比实际晚13个小时,而服务器的时间是东八区没问题。解决方法:连接数据库url中加上serverTimezone=GMT%2b8
2、java.sql.SQLException: The connection property 'zeroDateTimeBehavior' acceptable values are: 'CONVERT_TO_NULL', 'EXCEPTION' or 'ROUND'. The value 'convertToNull' is not acceptable.
在mysql8中,修改了zeroDateTimeBehavior的值,而老代码是用的convertToNull,所以会报错。解决方法:修改为CONVERT_TO_NULL,或者使用8.0.13及以上版本的驱动。
在8.0.13 release note中提到一点
==Connector/J now translates the legacy value of convertToNull for the connection property zeroDateTimeBehavior to CONVERT_TO_NULL. This allows applications or frameworks that use the legacy value (for example, NetBeans) to work with Connector/J 8.0. (Bug #28246270, Bug #91421)==
使用老的写法时,在解析时自动翻译成新写法,以此来兼容,就不用改配置啦。