The connection property 'zeroDateTimeBehavior' only accepts values of the form: 'exception', 'round'

The connection property 'zeroDateTimeBehavior' only accepts values of the form: 'exception', 'round' or 'convertToNull'. The value 'convertToNull ' is not in this set.


这个问题是解决以下问题出现的:
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
问题原因是因为JDBC 
url=jdbc:mysql://xxx.aliyuncs.com:3306/xxxxx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
字符串后面因为是从网页上复制的,后面多了一个空格。
错误信息中已经提示了 zeroDateTimeBehavior 属性可以接受 'exception', 'round' or 'convertToNull'中的一个。

只是因为后面多出的空格是不可见字符,所以很难看出问题。


默认是 exception,抛出异常

round 是返回:0001-01-01 00:00:00.0

convertToNull  就是转换为 null

======================文档信息========================

版权声明:非商用自由转载-保持署名-注明出处

署名(BY) :testcs_dn(微wx笑)

文章出处:[无知人生,记录点滴](http://blog.csdn.NET/testcs_dn)

==============欢迎关注我的个人微信订阅号(微wx笑)============


你可能感兴趣的:(java,exception,jdbc,Connection,property)