zoukankan      html  css  js  c++  java
  • mybatis模糊查询匹配汉字查询不出来数据,匹配字符和数字却可以的问题解决

    最近遇到了个没遇到过的问题 花费了很长时间去解决

    问题大致是这样的:比如 user表里一条数据 name: 张三ABC23    age :15 

    在模糊查询控制台打印的sql:select * from user where name like '%张三%'  我粘贴这条sql去数据库查询是可以查询到的 在程序中却不行

    然后把sql换了匹配查询的列 sql:select * from user where agelike '%5%'  这样却可以了,百思不得其解。经过很多的测试 我发现了规律

    只要匹配汉字查询就查不出来。sql:select * from user where name like '%ABC%'  这样也可以。。。

    最后的解决办法是 数据库连接后面没加字符编码

    jdbc:mysql://localhost:3306/xxx?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=UTC

    后来我在其他电脑上试的时候不加字符编码也没得问题,所以我猜可能mysql版本有关系

  • 相关阅读:
    Set Matrix Zeroes
    Summary Ranges
    Triangle
    MongoDB基本使用
    PHP Liunx 服务安全防范方案
    linux lvs 配置
    Linux下cacti的安装
    linux_nmon监控方法
    linux下rsync命令详细整理
    虚拟机安装CentOS以及SecureCRT设置【完美无错版】
  • 原文地址:https://www.cnblogs.com/pan-my/p/14204750.html
Copyright © 2011-2022 走看看