当前位置:网站首页>Solve the error string value: '\xf0\x9f\x98\xad',... 'for column' commentcontent 'at row 1
Solve the error string value: '\xf0\x9f\x98\xad',... 'for column' commentcontent 'at row 1
2022-07-26 04:31:00 【Rk..】
demand : analysis excel form , take excel Insert the data in the database
There is such a problem when inserting data into the database :
### Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xB1\xF0\x9F...' for column 'describe' at row 1
; uncategorized SQLException; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x90\xB1\xF0\x9F...' for column 'describe' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xB1\xF0\x9F...' for column 'describe' at row 1
What is outrageous is actually the front of the parsing table 300 This error does not appear in line , In the first 301 It's time to report sql abnormal . The first thing I think about is whether it will be 301 Will the row data have a special format , It turned out that there was no , But the data content is different , There is no special format , Checked for half an hour , The result is that the database is incorrectly encoded .
The reason is that some of our tabular data have been parsed into expressions , These expressions are encoded in four bytes and one unit , And what we usually use utf-8 Encoding in mysql The default in the database is 3 One byte, one unit , It is for this reason that data is stored mysql There was an error in the database .
I divide it into the following three steps to solve :
(1)、 see mysql Coding of database
show variables like 'character_set_database';
If it is urf8 Need to change to uft8mb4
(2)、 Modify the code of the data table to utf8mb4
ALTER TABLE TABLE_NAME CONVERT TO CHARACTER SET utf8mb4;You can also directly use the graphical interface to change
(3)、 Modify the connection code to connect to the database
jdbc:mysql://localhost:3824/reggie?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 It is amended as follows : jdbc:mysql://localhost/reggie
边栏推荐
猜你喜欢

解析Steam教育的课程设计测评体系

Which websites can I visit to check the latest medical literature?

Steam科学教育赋予课堂教学的创造力

What if win11 cannot wake up from sleep? Solution of win11 unable to wake up during sleep

UE4 靠近物体时显示文字,远离时文字消失

UE4 displays text when it is close to the object, and disappears when it is far away

QT compilation error sorting and remote module Download

UE4 键盘控制开关灯

qt编译报错整理及Remote模块下载

Array sort 3
随机推荐
Recognized again | saining network security has been listed in the ccsip 2022 panorama of China's network security industry
Sweet butter
UE4 通过按键控制物体的旋转
性能和成本的综合架构:单元化架构
egg-sequelize JS编写
Comprehensive evaluation and decision-making method
Use Baidu PaddlePaddle easydl to complete garbage classification
Acwing刷题
MySQL log classification: error log, binary log, query log, slow query log
Steam科学教育赋予课堂教学的创造力
MySQL usage
Page pull-up refresh and pull-down loading
UE4 controls the rotation of objects by pressing keys
How to write the introduction and conclusion of an overview paper?
第三篇如何使用SourceTree提交代码
idea插件离线安装(持续更新)
Credit card fraud detection based on machine learning
Array sort 2
一、基础入门
The auxiliary role of rational cognitive educational robot in teaching and entertainment