Solve the problem of garbled characters inserted into the MySql database. bitsCN.com
Solve the problem of garbled characters inserted into the MySql database.
The last semester of junior year is designed! Today, I helped you correct the problem. The website system needs to insert Chinese characters into the database. I changed both the Chinese character and the database encoding to UTF-8.
But the SQL statement executing the insert statement reports an error, saying it is garbled! I have been searching for a long time and tried many other methods to convert character format encoding or something!
Finally, I saw a sentence on the website.
Change the original
Jdbc: mysql: // localhost: 3306/YourDb
Change
Jdbc: mysql: // localhost: 3306/YourDb? UseUnicode = true & characterEncoding = UTF-8
After completing the above work, the Chinese characters inserted into mysql should not be garbled.
OMG !!! Okay, you also need to add the encoding format after connecting to the mysql database, so that JDBC inserts the string into the mysql database to use UTF-8. remember later.
And can be changed
Con = DriverManager. getConnection ("jdbc: mysql: // localhost: 3306/news? User = root & password = 123 & useUnicode = true & characterEncoding = UTF-8 ");
BitsCN.com