Upgrade MySql to support emoji and utf8mb4
Some children's shoes do not have a deep understanding of Emoji expressions. They are reluctant to use Emoji and do not want to go to Baidu.
Emoji is a character, not an image. If it is not supported by the client or database, upgrade it. the browser is also used. Since it is a character, can it be replaced manually? Yes. In fact, you can upgrade the relevant component version. Emoji is not Apple's exclusive expression. It belongs to unicode and is a standard, not a private solution. Everyone can use it happily without conversion.
-- In fact, this simple problem is always drunk.
However, even upgrading mysql is not easy. I thought it would be okay to upgrade the database and change the encoding, but it was not that easy after the test. I don't know if it is a problem with the MySql client. The same is true for NativeCat and the official Workbench.
The client adaptation is not feasible ...... The drop-down menu does not support any choice ......
References:
Http://bbs.csdn.net/topics/390055415http://stackoverflow.com/questions/13653712/java-sql-sqlexception-incorrect-string-value-xf0-x9f-x91-xbd-xf0-x9fhttp://afei2.sinaapp.com? P = 518 & utm_source = tuicool & utm_medium = referralhttp: // reset (replacement method)
Copy a command
alter table foo.foo convert to character set utf8mb4 collate utf8mb4_unicode_ci
Then the Java code must declare this:
SET NAMES 'utf8mb4'
To insert an Emoji.
Mysql Configuration
[client]default-character-set = utf8mb4[mysqld]character-set-server=utf8mb4collation-server=utf8mb4_unicode_ci[mysql]default-character-set = utf8mb4
In addition, upgrade the JDBC driver.
Test the code. You can also check whether your browser correctly displays the Emoji expression (it cannot be a question mark or square. Upgrade your browser !).
Oh mygod, CSDN database plug-in! It will be interrupted if you encounter the Emoji character! I still need to use images.
Import java. SQL. Connection;
Import java. SQL. DriverManager;
Import java. SQL. PreparedStatement;
Import java. SQL. ResultSet;
Public class Test {
Public static void main (String [] args ){
System. out. println ("test string =" +"