Caused by: java.sql.SQLException: Incorrect string value

问题描述

1
Caused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x80\xE3\x80...' for column 'show_content' at row 1

解决办法

修改mysql数据库的编码为uft8mb4

1
ALTER SCHEMA TableName DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci ;

修改数据表的编码为utf8mb4

1
ALTER TABLE TableName CONVERT TO CHARACTER SET utf8mb4;

修改连接数据库的连接代码

1
url: jdbc:mysql://127.0.0.1:3306/crawler?useUnicode=true&character_set_server=utf8mb4&useSSL=false
坚持原创技术分享,您的支持将鼓励我继续创作!