Com.mysql.jdbc.MysqlDataTruncation:Data truncation:truncated Incorrect DOUBLE value: ...

Source: Internet
Author: User
Tags truncated



When using MyBatis's @update annotations, I reported one such mistake.


### Error updating database.  Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: ‘4028158162c347830162c347fb050000‘

### The error may involve com.xwj.mapper.UserMapper.updateUser-Inline

### The error occurred while setting parameters

### SQL: UPDATE xwj_user SET last_name = ? WHERE id = 2

### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: ‘4028158162c347830162c347fb050000‘

; ]; Data truncation: Truncated incorrect DOUBLE value: ‘4028158162c347830162c347fb050000‘; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: ‘4028158162c347830162c347fb050000‘] with root cause


com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: ‘4028158162c347830162c347fb050000‘

   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3974) ~[mysql-connector-java-5.1.46.jar:5.1.46]

   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912) ~[mysql-connector-java-5.1.46.jar:5.1.46]

   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530) ~[mysql-connector-java-5.1.46.jar:5.1.46]

   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683) ~[mysql-connector-java-5.1.46.jar:5.1.46]

   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486) ~[mysql-connector-java-5.1.46.jar:5.1.46]





The method to invoke is as follows:

/**

    * update

    */

   @Update("UPDATE xwj_user SET last_name = #{lastName} WHERE id = ${id}")

   int updateUser(@Param("lastName") String name, @Param("id") String id);




On the internet to see a variety of solutions, there is said to be a set statement in the comma mistakenly written and caused by the landlord encountered is not the case



Look at the above error, that is the ID field in the database (length varchar (32)) is '4028158162c347830162c347fb050000' This data length caused by too long. Then the ID of this data is changed to ' 1 ', one executes, and the execution is found to be successful. The landlord will be proud of the ID is too long caused by.



But in the mind also strange database can put 32, why will error? So I want to find out, ID field how many bits, will be error. then change the ID to be ' 12 ', then ' 123 ' ... Add, in turn, until added to the ' 12345678901234567890123456789012 ', altogether 32, still carry out success, this time the landlord will be ignorant force. How can this be done?



Suddenly a flash of light, it is possible to observe whether the ID is not a full number caused it? Then change one of the numbers to a letter, then execute the error. Kung Fu is a conscientious, finally found the culprit



As to why the ID must be a pure number, I hope that the great God in the comment area message, again brother thanked ~






Com.mysql.jdbc.MysqlDataTruncation:Data truncation:truncated Incorrect DOUBLE value: ...


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.