Inserting time in MySQL database with MyBatis error: Incorrect datetime value: ' For column ' at row 1

Source: Internet
Author: User

Problem Description: The MySQL used is 5.1.37 version, with the Mysql-connector-java-5.0.4.jar version, the field defined in the Java file is a date type, the field type defined in MySQL is a datetime type,

Try the following methods are unsuccessful, the report of the error is still one, the method is as follows:

1. The first method:

Date date = new Date ();
Shop.setlastedittime (date);

2. A second method:

SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
Timestamp ts = new Timestamp (System.currenttimemillis ());
String strdate = Sdf.format (ts);
Shop.setlastedittime (timestamp.valueof (strdate));

Later Baidu Check bar, said there may be a jar version conflict problem, but the original code can be run, and here can not run, try to introduce themselves into the package Mysql-connector-java-5.0.4.jar replaced by the high version, the problem successfully resolved.

Later try to start from which version of the problem, it is mysql-connector-java-5.0.5.jar start after the beginning of a few versions are all the same.

The above two methods can be used after switching to a few jar packages of a higher version.

Specific reasons for not knowing what MySQL has done optimized, just know the solution, there is a welcome to know the reason for the next

Inserting time in MySQL database with MyBatis error: Incorrect datetime value: ' For column ' at row 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.