`
bozch
  • 浏览: 456012 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci

sql 
阅读更多
事情是这样晒的,有两个独立部署的web服务器环境A和B,A的数据库和B的数据库几乎是一样的(库、表、字段、数据),也有可能没发现不一样的地方。A正常,B请求异常,如下所示:

### Error querying database. Cause: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=' ### The error may exist in URL [jar:file:/data/yangtun_show/6_cgp/scp-cgp.jar!/BOOT-INF/classes!/mapper/CaseRegistrationMapper.xml] ### The error may involve com.bjzhianjia.scp.cgp.mapper.CaseRegistrationMapper.getStatisByDept-Inline ### The error occurred while setting parameters ###
SQL: xxxxxxx and ?<=crt_time and crt_time <= ? and yyyyyyyyyyy### Cause: java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=' ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1267]; Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<='; nested exception is java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<=

这样的问题出现了,好像没见过(不要慌,拿起想起拍个照,然后发个朋友圈)。定位问题需要从头开始,哪个个web接口发起的请求,后台做了什么处理,数据库执行的时候SQL现场是什么样子的。

思路有了,开始在B中还原现场。从web发起请求的接口是http://i.love.you:forever/queryPath?startTime=2020-04-00+00:17:16&endTime=2020-07-22+00:17:16,复盘成功。发现了奇怪的地方,请求参数中startTime=2020-04-00+00:17:1有00,换成01试试http://i.love.you:forever/queryPath?startTime=2020-04-01+00:17:16&endTime=2020-07-22+00:17:16,成功了。 问题解决了!

Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,NUMERIC) for operation '<='; 看来并不可怕,但是。。。。。。



why?A行,B不行原因是什么呢?
应该有两种可能性:第一是web程序对日期解析支持不同,可能受操作系统影响;第二是数据库本身支持对异常日期的解析。

继续探索。。。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics