MySQL中date类型的空值0000-00-00和00:00:00

1.如果mysql中使用了date类型,并且默认值为'0000-00-00',

   那么数据库中的'0000-00-00 00:00:00', '0000-00-00', '00:00:00'这三个值是相等的,都为空

2.在java中使用ResultSet的getString()返回结果时,如果出现如下异常:

    java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date

    那么在mysql连接的url后面加上 zeroDateTimeBehavior=convertToNull即可,如:

  jdbc:mysql://localhost/driver_center?zeroDateTimeBehavior=convertToNull

3.以上数值,通过ResultSet的getString()返回的结果为null

原文地址:https://www.cnblogs.com/tommy-huang/p/6144994.html