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