Java insert data, garbled problem

Check whether the database encoding format is utf8

show variables like 'character%'

 

View database connection profiles

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=root

 

Pay special attention to:
jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=UTF-8

 

This only applies to xml files. If you configure it as a properties file and read data, garbled characters will still appear.
In the properties file  amp; to remove the writing as follows:


jdbc:mysql://localhost:3306/databaseName?useUnicode=true&characterEncoding=UTF-8

debug trace the data to see where the data goes wrong.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326679193&siteId=291194637