问题
I m having a tomcat server having a connection pool to mysql.
In the connection settings i can see all the character set encodings set to utf8mb4 in *this page except for character_set_results.
My connection string being -
jdbc:mysql://:3306/abc?character_set_server=utf8mb4&useOldAliasMetadataBehavior=true&character_set_connection=utf8mb4&characterEncoding=utf-8&character_set_results=utf8mb4
In the mysql server i can see character_set_results showing utf8mb4.
But in the jsp page it is not shown anyway.
The mysql version is 5.6.16 and connector version is 5.1.22
Regards
回答1:
connection settings need not characterEncoding and character_set_server, mysql connectorJ will auto check.
make sure character_set_database=utf8mb4,character_set_server=utf8mb4, Table character set=utf8mb4, some columns use varchar character set=utf8mb4;
tip: character_set_server=utf8mb4 need config my.ini Exemple:
[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'
loose-default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
loose-default-character-set = utf8mb4
https://dev.mysql.com/doc/refman/5.6/en/charset-unicode-utf8mb4.html?spm=5176.2020520165.110.53.AlPmXp
来源:https://stackoverflow.com/questions/24389862/mysql-connectorj-character-set-results-does-not-support-utf8mb4