mybatis 插入数据中乱码

今天在学习mybatis时 发现插入数据库的中文数据乱码,

网上上说有问题有两种;

1、数据库编码类型不是utf8;检查后发现不是这个

2、数据库连接的问题。解决方案是 jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8 加上后缀;

然后我就在mybatis的conf.xml里加上后缀结果报错

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.sql.SQLException: The connection property 'useUnicode' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'true;characterEncoding=utf8' is not in this set.
### Cause: java.sql.SQLException: The connection property 'useUnicode' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'true;characterEncoding=utf8' is not in this set.
 

   才发现要使用转义符号  '&' &

 jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值