Java Web Development notes (4)

Source: Internet
Author: User

Database garbled problem, mainly from the following aspects of consideration:

1. Database encoding Format

SHOW VARIABLES like '%char% '; View, if there is Latin need to change to the corresponding format (typically Utf-8), need to be in the global configuration, changing the MySQL folder under the My.ini file

[Mysqld] 2 character-set-server=[client]default-character-set=5 [MySQL]  Default-character-set=utf8      

Please refer to http://blog.csdn.net/u012410733/article/details/61619656 for details.

After changing the SQL statement insert a Chinese record in the database, if it can be displayed correctly, there is no problem here.

2. When connecting to a database

1 // Load Database driver, register to drive manager 2 String url = "Jdbc:mysql://localhost:3306/supermarketmanagesystem?useunicode=true& Characterencoding=utf-8 "//  Database connection string 3//  database user name 4   Database Password 5 conn = drivermanager.getconnection (URL, username, password);

In line 2nd? useunicode=true&characterencoding=utf-8 "no less

Java Web Development notes (4)

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.