Unknown character set index for field '255' received from server is still there with matching encoding in url for 8.0.29 mysql connector

oalqel3c  于 2022-12-22  发布在  Mysql
关注(0)|答案(1)|浏览(271)

This error while making connection to the mysql database.

Class.forName("com.mysql.jdbc.Driver");
        
String user = "root";
String password = "password";
String url = "jdbc:mysql://localhost:3306/std_record?characterEncoding=utf8";
        
Connection con = DriverManager.getConnection(url, user, password);

The url is used with utf8 and without it and with cp850 endcoding but error is still there. Mysql connector version: 8.0.29
The following is database character encoding:

mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+---------------------------------------------------------+
| Variable_name            | Value                                                   |
+--------------------------+---------------------------------------------------------+
| character_set_client     | cp850                                                   |
| character_set_connection | cp850                                                   |
| character_set_database   | utf8mb4                                                 |
| character_set_filesystem | binary                                                  |
| character_set_results    | cp850                                                   |
| character_set_server     | utf8mb4                                                 |
| character_set_system     | utf8mb3                                                 |
| character_sets_dir       | C:\Program Files\MySQL\MySQL Server 8.0\share\charsets\ |
+--------------------------+---------------------------------------------------------+
8 rows in set (0.09 sec)
jljoyd4f

jljoyd4f1#

I've had the same with mysql driver: mysql-connector-java-3.0.17-ga-bin.jar I've changed it to mysql-connector-java-8.0.17.jar and it work fine.
I've seen also that 5.1.40 should be enough: unknown character set index for field '255' received from server

相关问题