Unknown initial character set index '255' received from server. Initial client character set can be ... 解决方法

转载自: https://blog.csdn.net/txwtech/article/details/80787886

 

Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.

从错误的提示信息中发现字符集设置出现问题

 

 

mysql连接数据库时报此错误:

//String url = "jdbc:mysql://localhost:3306/db_cjky" 如果使用这句就会报错。
//Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.
String url = "jdbc:mysql://localhost:3306/db_cjky?useUnicode=true&characterEncoding=utf8";//改成这句,就可以了

 

最终解决方法:

删除 \WebContent\WEB-INF\lib目录下的。mysql-connector的jar文件。原因是:MySQL驱动和数据库字符集设置不搭配

 

再补充一下,如果是在mybatis配置文件中的话应该修改成jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=utf8

 

posted @ 2020-08-18 01:48  大厨无盐煮  阅读(1277)  评论(0编辑  收藏  举报