Myeclipse+hibernate writing MySQL data garbled problem

Source: Internet
Author: User
First, to unify the MyEclipse character encoding, the steps are as follows: 1, enter the default (GBK) in the Window--preferences--general--workspace,text file encoding option Change the option to other and set the value to Utf-8;2, enter Window--preferences--myeclipse--files and Editors, and this option will be the following: ASP and PHP, CSS, DTD, HTML, JSP, The character encodings in the XML are all changed to utf-8;3, and if necessary, add this line of code to all JSP page headers: <%request.setcharacterencoding ("UTF-8"); %>, prevent the page to pass the value of the time garbled; 4, if you call the servlet file, add the following two lines of code in the servlet file: request.setcharacterencoding ("UTF-8"); Response.setcharacterencoding ("UTF-8");

Next, set up the Hibernate profile:

Hibernate.cfg.xml plus attributes.
<property name= "Connection.useunicode" >true</property>
<property name= "Connection.characterencoding" >UTF-8</property>

Finally, the character encoding of the database should also be set:

Modify database encoding: ALTER DATABASE name character Set UTF8

Open the MySQL installation directory under the configuration file My-default.ini find Default-character-set This line and modify the Default-character-set=utf8, if not add this sentence.

Myeclipse+hibernate writing MySQL data garbled problem

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.