In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Caused by: java.sql.SQLException: Incorrect string value:'\ xF0\ x9F\ x94\ xA5' for column Emoji emoticons are stored in Mysql Times error.
Ios emoji (emoji emoji), although this emoji is utf8 encoding, but a character needs to occupy 4 bytes, while MySQL utf8 encoding can only store 3 bytes of characters. In MySQL 5.6, you can set the encoding to utf8mb4, which is a superset of utf8.
1. Modify the MYSQL character set
Mysql sets the character encoding set to utf8mb4, and the corresponding library, table, and field to utf8mb4. Note that if the existing table utf8 coding set is changed to utf8mb4, the library, table, and field should be set and checked once. If only the corresponding table and field of the library will not change, so will the table change. You may also need to restart the database if you change the configuration.
Character_set_server=utf8mb4
2. Upgrade JDBC
Lower versions of JDBC will appear garbled, facial expressions, and even Chinese garbled.
Here are some corresponding situations of the JDBC version, such as the following figure, the JDBC version supports EMOJI, the picture found on the Internet, my 5.1.6 test inserts and displays Chinese and Emoji emoticons are normal.
3, inherit the configuration of the server jdbc:mysql://xxx.xxx.xxx.xxx:3306/dbwww58com_chrcsm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true connection address after the parameter is set to UTF-8 or can be automatically identified, if you can not try to remove the bold part, let the connection automatically identify the server configuration. The details are related to the JDBC version. Inherit the configuration of the server jdbc:mysql://xxx.xxx.xxx.xxx:3306/dbwww58com_chrcsm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true connection address after the parameter is set to UTF-8 or can be automatically identified, if you can not try to remove the bold part, let the connection automatically identify the server configuration. The details are related to the JDBC version.
4. Set the init_connect parameters of MYSQL
After setting it, you can verify it through show variables like 'init_connect';, as shown in the following figure 2 init_connect parameter query:
5, the code set in the code may be because of the JDBC version, I use this way, insert and query can be carried out normally. Connection.prepareStatement ("set names utf8mb4"). ExecuteQuery (); and then insert it through connection.prepareStatement. The code set may be set in the code because of the JDBC version. I use this way, inserting and querying can be done normally. Connection.prepareStatement ("set names utf8mb4"). ExecuteQuery (); and then insert it through connection.prepareStatement.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.