About Java reading the default value of the date type field in mysql '0000-00-00'

Today, in the process of doing the project, I always encounter this problem when querying the data in a table:

com.jfinal.plugin.activerecord.ActiveRecordException:

 Value '0system c4ca4238a0b923820dcc509a6f75849b12006-08-30 00:00:00system1

‘ can not be represented as java.sql.Timestamp

Check the database and find that a certain field is datetime type, and the field value is '0000-00-00';

Debug the code. When jfinal executes sql query, the query result ResultSet is converted to List<Record> and an error is reported.

    Finding the information found: add zeroDateTimeBehavior=convertToNull after the database connection url, the problem is solved.

   "0000-00-00" is a special value in mysql, as the default value of the date type variable. Java treats it as an illegal value, causing errors.

  The date type variable in mysql will encounter similar problems, but its default value is "0000-00-00". The solution is the same.

Guess you like

Origin blog.csdn.net/xiaozaq/article/details/89188722