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

created at 08-17-2021 views: 162

error message

### Error querying database.  Cause: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property.
### The error may exist in com/dy/dao/mapping/userDao-mapping.xml
### The error may involve com.dy.dao.UserDao.findUserById
### The error occurred while executing a query
### Cause: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property. 

reason

The driver does not match the database character set

The mysql database version is mysql-8.0.23-winx64

The driver is:

<dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.12</version>
</dependency>

Solution1

1. Add character set description in url

"jdbc:mysql://localhost:3306/mybatis?characterEncoding=utf8"

solution2

Change to a new version of mysql-connector-java

<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.44</version>
</dependency>
created at:08-17-2021
edited at: 08-17-2021: