Java - When inserting data with empty value into the database, it says that my data is too long.
漂亮男人
漂亮男人 2017-05-25 15:08:09
0
2
662

When inserting null data into the database, the error message Data truncation: Data too long for column 'REPLY_TYPE' at row 1, this field is set to varchar(20), and the character set of the program and table is utf_8

漂亮男人
漂亮男人

reply all(2)
洪涛

Try, jdbc:mysql://xxx.xxx.xxx.xxx:3306/xxxxxx?useUnicode=true&characterEncoding=utf8

Guarantee: database, tables, fields, program encoding, and jdbc connection are all utf-8

伊谢尔伦

I was all in tears. I finally found out. It was because the order of my database fields was inconsistent with the order of insertion in the java code. Long ones were inserted into character types and short ones were restricted.
insert into table name values ​​(?,?) is a must. The order is consistent with the fields in the table
insert into table name (field name, field name) values ​​​​(?,?) This order can be inconsistent
I guess it is only a novice like me who makes this mistake

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!