Hibernate inserts mysql Chinese garbled Solution

Source: Internet
Author: User
Hibernate inserts mysql Chinese garbled characters to solve the problem of mysql version 5.5 ??????? Some time ago, I reinstalled the system and learned about hibernate. When I first started using the oracle database, there was no Chinese Garbled text. However, after converting to mysql, I inserted Chinese characters and then Garbled text, I thought it was the cause of incorrect encoding format when installing mysql, and then uninstalled it again.

Hibernate inserts mysql Chinese garbled characters to fix mysql version 5.5? ?????? Some time ago, I reinstalled the system and learned about hibernate. When I first started using the oracle database, there was no Chinese Garbled text. However, after converting to mysql, I inserted Chinese characters and then Garbled text, I thought it was the cause of incorrect encoding format when installing mysql, and then uninstalled it again.

Solve Chinese garbled characters inserted into mysql by hibernate

My mysql version 5.5

?

?????? Some time ago, I reinstalled the system and learned about hibernate. When I first started using the oracle database, there was no Chinese Garbled text. However, after converting to mysql, I inserted Chinese characters and then Garbled text, I thought it was the reason why I chose the wrong encoding format when installing mysql, and then uninstalled and re-installed it. As a result, I installed it multiple times, but the same garbled code. I tried it on the Internet and then tested it myself, two solutions:

1. Change the connection string

Jdbc: mysql: // localhost/hibernate? UseUnicode = true & characterEncoding = GBK

This method was used at the beginning and can solve the problem of inserting Chinese garbled characters. However, since I have been using navicat to connect to the database, it is more convenient. There is no garbled Chinese characters and I have never used the console, today, when I used the console to connect to the database, Chinese characters were garbled. Solution 2

2. Open the mysql Chinese installation directory and open my. ini changes the default-character-set value to GBK, and the character-set-server value to utf8. After the change, no garbled code occurs when hibernate is inserted into the database, and no garbled code is found on the console, the connection string can finally be changed back to jdbc: mysql: // localhost/hibernate, which does not have to be so long. For other MySQL versions, it is not clear but should be similar, search character to find the encoding format.

Last friendly reminder: Remember to back up the source file before changing my. ini to prevent exceptions.

(This article is only intended for the same people as me. Please ignore it)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.