1. 程式人生 > 資料庫 >Cause: java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\x80--...‘ for column ‘html_b

Cause: java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\x80--...‘ for column ‘html_b

 <property name="connectionInitSqls" value="set names utf8mb4;" />
useUnicode=true&amp&allowMultiQueries=true&autoReconnect=true&charset=utf8mb4

my.ini

[client]
default-character-set = utf8mb4  
 
[mysql]
default-character-set = utf8mb4  
 
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'  
ALTER DATABASE 資料庫名 CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

alter table 表名 convert to character set utf8mb4 collate utf8mb4_bin;