Explain the function of static keyword and final keyword in Java in detail>>>
Today, when writing the code, I found that Chinese was stored in MySQL garbled
Hibernate for my data persistence framework. First of all, I confirm that the Chinese data transferred from JSP page to the background is not garbled, so I am sure that there is something wrong with the storage of Chinese data. Looking up information on the Internet, many people say that you can add the following in the configuration file of Hibernate:
<propertyname="connection.characterEncoding">utf-8</property>
After adding this sentence, I still can’t. Keep looking up the information. Then, it suddenly occurred to me that I didn’t specify the code when I built the database, and the data used the default code of MySQL (and the default code of MySQL was determined during installation). So I delete the existing database (small project, it doesn’t matter to delete it), rebuild the database, and specify the code when building the database
createdatabase`db_photodisplay`defaultcharactersetutf8collateutf8_general_ci;
After the database is built, the table is rebuilt. New errors occurred in the operation of the project
Data truncation: Data too long for column ‘rolename’ at row 1
Continue with the mistake of Baidu. Someone on Baidu said that it would be better to add engine = InnoDB default character set = utf8 when creating tables
So I deleted the table and added engine = InnoDB default character set = utf8 when creating the table
CREATETABLE`role_info`(
`id`bigint(20)NOTNULL,
`rolename`varchar(50)NOTNULL,
PRIMARYKEY(`id`)
)engine=innodbdefaultcharacterset=utf8
Re run the project, found that the Chinese data successfully stored in the database, no garbled
Similar Posts:
- Mysql Error when creating table: Tablespace for table `tablexx` exists. Please DISCARD the tablespace before IMPORT.
- How to Solve Mysql Error 1206: The total number of locks exceeds the lock table size
- When mysql creates a table, set timestamp DEFAULT NULL error 1067-Invalid default value for’updated_at’
- Unknown system variable ‘storage_engine’
- Database Insert error: ora-06550 [How to Solve]
- Incorrect key file for table [How to Solve]
- [Solved] Plugin ‘FEDERATED’ is disabled. /usr/sbin/mysqld: Table ‘mysql.plugin’ doesn’…
- [Err] 1214 – The used table type doesn’t support FULLTEXT indexes
- How to Solve SQL fulltext error
- mysql: [Err] 1075 – Incorrect table definition; there can be only one auto column and it must be d…