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)