JDBC 和 Mybatis连接mysql数据库的时候,设置字符集编码

jdbc连接mysql数据库的时候,设置字符集编码!!!

可以如下配置,mysql可直接在url后面加上字符集设置


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


Mybatis连接mysql数据库的时候,设置字符集编码!!!

可以如下配置,Mybatis的配置文件中要这样写:(注意要用转义 & 代替&)


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

猜你喜欢

转载自blog.csdn.net/jdnicky/article/details/79937406