mysql is a very commonly used data database in our projects. But because we need to save Chinese characters in the database, we often encounter database garbled characters. Let's take a look at how to solve the problem of garbled characters when Java inserts data into the database.
Add useUnicode=true&characterEncoding=UTF-8 parameters after the url configured in the database.
private static String URL = "jdbc:mysql://localhost:3306/ki?useUnicode=true&characterEncoding=UTF-8"; private static String USER = "root"; private static String PASSWORD = "root";
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of Solution to Chinese garbled characters in Java database. For more information, please follow other related articles on the PHP Chinese website!