When JDBC and Mybatis connect to the mysql database, set the character set encoding

When jdbc connects to the mysql database, set the character set encoding!!!

It can be configured as follows, mysql can directly add the character set setting after the url :


String url = "jdbc:mysql://localhost:3306/exceltest1?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";


When Mybatis connects to the mysql database, set the character set encoding!!!

It can be configured as follows, which should be written in the configuration file of Mybatis: (note to use escape & instead of &)


<property name="url" value="jdbc:mysql://localhost:3306/exceltest1?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull"/>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325753685&siteId=291194637