当前位置:Gxlcms > 数据库问题 > JDBC 和 Mybatis连接mysql数据库的时候,设置字符集编码

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

时间:2021-07-01 10:21:17 帮助过:3人阅读

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"/>

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

标签:local   lte   value   string   host   字符   cte   配置文件   nbsp   

人气教程排行