• 数据库表的字符集编码报错问题


    一、错误描述

    org.springframework.jdbc.UncategorizedSQLException: 
    ### Error querying database.  Cause: java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
    ### The error may exist in com/herin/api/modules/rockpressure/mapper/mysql/KyWzPowerMapper.java (best guess)
    ### The error may involve defaultParameterMap
    ### The error occurred while setting parameters
    ### SQL: SELECT  id,area_name,value,create_time  FROM ky_wz_power     WHERE (area_name = ?) AND create_time >=(DATE_FORMAT( NOW(), '%Y-%m-%d' ) - INTERVAL 7 DAY)
    ### Cause: java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
    ; uncategorized SQLException; SQL state [HY000]; error code [1267]; Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='; nested exception is java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
    	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
    	at com.sun.proxy.$Proxy96.selectList(Unknown Source)
    	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    Cause: java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation ‘=’

    二、解决方案

    改变数据库表的字符集

    ALTER TABLE `ky_wz_power` CONVERT TO CHARACTER SET utf8;
    
    • 1
  • 相关阅读:
    MySQL表操作
    ctf-pikachu-ssrf
    如何实现矩阵的重采样问题
    Vue3 + Naive-ui Data Table 分页页码显示不全
    2022年全球及中国疏水阀行业头部企业市场占有率及排名调研报告
    led护眼灯真的能护眼吗?Led护眼灯的好处
    Linux主机间的相互免秘钥
    react-redux action传参 多个state处理
    一文搞懂Go读写Excel文件
    提升B端图表设计技能:教程分享
  • 原文地址:https://blog.csdn.net/hznb_369/article/details/127667036