I have not been the first to configure the database so I have not found this problem, Baidu found on the network and there is no corresponding solution, so I began to explore their own solution to the problem.
The problem is roughly the same, there is a table in the database, and when I delete the Ganso in the table in the Java code, there is no way to remove the Chong from the Chinese attribute value. may not be very accurate, and then I will cooperate with the picture to explain it.
Tools/Materials
Method/Step
- In general, this problem is due to the fact that the database and the compilation environment use a different encoding, in order to facilitate the explanation I give a student information table for example.
For example, there is now a student named Xiao Ming (char type), the corresponding study number is 1 (INR type), according to the number of students to delete the number 1 Xiao Ming executive results without any problems, according to the name of the deletion of the name of Xiao Ming can not be deleted. If you have the same problems as I do then look down, if not that may not help you in the following content.
- First, check the text encoding of the current database.
SHOW VARIABLES like ' character_set_% '
- I am using the MySQL database, the code is as follows:
- The workaround is simple to add a sentence after the database connection statement? USEUNICODE=TRUE&CHARACTERENCODING=GBK on the line.
String url = "Jdbc:mysql://localhost:3306/db_databaseuseunicode=true&characterencoding=gbk"; String user = "root"; String PassWord = "root";
The coding problem between Java and MySQL