标签:参数 pre str utf8 amp com password 语句 连接数据库
今天写个小demo的时候发现sql语句里面的username为中文的时候就不能查到正确结果,sql语句如下:
String sql = "select * from user where username=? and password=?";
但是在navicat里面直接查询就能显示,如下图:
这说明了sql语句的中文并没有能正确转化
最后找到了解决办法,在连接数据库的url后面添加?useUnicode=true&characterEncoding=utf8
"jdbc:mysql://localhost:3306/sql_injection?useUnicode=true&characterEncoding=utf8";
标签:参数 pre str utf8 amp com password 语句 连接数据库
原文地址:https://www.cnblogs.com/lzxin/p/10067167.html