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 


版权声明:本文为wjx25zj原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。