0
点赞
收藏
分享

微信扫一扫

Mybatis学习中遇到的错误java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (ut


在Mybatis学习存储过程调用的时候,老是出现【java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='】这个错,百度了下意思是返回的结果有两种字符集。一般这种情况在排除编程语言中单独设置的字符集错误后,首先想到的就是数据库中的数据表设置的字符集类型和编程语言中所要得到的结果类型不一致导致的。下面介绍具体的解决办法:

1   输入sql语句:首先看看表结构的类型(一般设置为UTF-8),支持中文类型的:


<span style="font-size:18px;">SHOW VARIABLES LIKE 'character_set_%';</span>

Mybatis学习中遇到的错误java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (ut_存储过程


再查看下字段类型:


<span style="font-size:18px;">SHOW VARIABLES LIKE 'collation_%';</span>

Mybatis学习中遇到的错误java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (ut_数据库_02



看到这两处的类型有不是UTF-8的地方了吗?全部都要改成UTF-8类型的:

set character_set_database =utf8;
set character_set_results =utf8;
set character_set_server =utf8;
set character_set_system =utf8;


SET collation_server = utf8_general_ci
SET collation_database = utf8_general_ci


按道理这样就能成功了,但是有几个地方也要注意一下:

 2  数据库中数据表:

Mybatis学习中遇到的错误java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (ut_数据库_03

3 数据库:

Mybatis学习中遇到的错误java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (ut_数据库_04


4





举报

相关推荐

0 条评论