MySQL database 04 to read data processing distortion

Sometimes we will find jdbc or mybatis hibernate or data read from the database is garbled, how to deal with it in this way?

1, with the proviso

  • We must ensure that the data in the database itself is not garbled

    2, Procedure

  • Access database query parameters plus a few behind url
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8

UseUnicode characterEncoding provided with the following effect:
when writing data, the database will first use UTF-8 format when the decoded data items stored data into byte code, and then decoded again using the bytecode is stored in the database encoding GBK ; the data is read, at the time of access to data from the database, the database data in the database will be decoded by the first format into byte code GBK, and then again after the re-decoding the byte code format encoded by UTF-8 data, then the final data is returned to the client.
Url above configuration database can be successfully solved the problem of garbled data read.

Guess you like

Origin www.cnblogs.com/alichengxuyuan/p/12519960.html