Process Chinese garbled characters when hibernate connects to MySQL

Source: Internet
Author: User

I used MySQL when developing javaee. At that time, the server used Linux. I wrote everything, but the characters displayed on the interface were always "?". ", At that time, I thought the encoding for storing the database was incorrect! I found that the database encoding in MySQL is also utf8 (I configured UTF-8 in struts2)

At that time, I had a headache. javaee had been working for a long time. Why was there such a problem? At that time, I checked a lot of information and I was not satisfied with it, I finally read the English explanation on Google (poor English, usually skipping English). Foreigners mean that they need to append the character encoding format to the string connected to the database through hibernate, for example, if the database hello is requested, the connection character of the request is:

<Property name = "connection. url"> JDBC: mysql: // 3306/Hello? Useunicode = true & characterencoding = UTF-8 </property>

But after the connection, I found that the interface and the background promised "?",. At that time, I was very depressed. I had no choice but to continue reading some foreign articles. Finally, I realized that there was no problem with this writing method, and the key error problems existed "&". I want to change the above "&" to "& amp;". I have tried some of them, and this method can solve the problem. "?" This situation
Complete statement: JDBC: mysql: // 3306/Hello? Useunicode = true & amp; characterencoding = UTF-8

If this problem occurs in the future, you need to add character encoding for the link URL of hibernate!
Learning lies in accumulation!

Related Article

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: 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.