A new MySQL database table was created yesterday, and when inserting Chinese characters into Java, it was found that the insertion result in the database was garbled. The actual character set does not meet the problem.
There are a number of solutions to this problem, such as the Java and MySQL garbled problem in this article but I recommend that you delete the table by deleting the new table and setting the default character set to UTF-8 when the table is built, so that you can avoid any problems later.
You can view the encoding format of the table by using the statement Show CREATE TABLE table_name. For example mine is:
CREATE TABLE' blog ' (' title 'varchar( -) not NULL DEFAULT "', ' username 'varchar( -)DEFAULT NULL, ' content 'varchar( the)DEFAULT NULL, ' createtime ' dateDEFAULT NULL, PRIMARY KEY(' title ')) ENGINE=InnoDBDEFAULTCHARSET=Utf8
This is the modified statement, the initial view is that the encoding format is latin1, the Build Table tool uses Navicat, the default is to build the table is Latin1, you can select the "Options" tab in the table, select UTF-8 in the character set, such as:
Java inserting Chinese characters into MySQL is garbled