'com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure ,about mybatis

I'm using java's mybatis,I've implemented interface IBaseBusinessQuery, maping file set method -> T findOne(K var1).

I suspect the reason for the name of the variable,so,I rewrote this method -> @Override T_Permission findOne(String key);,but,the result is so.

implemented interface

public interface IBaseBusinessQuery<T, K> {
    T findOne(K var1);

    List<T> findAll();
}

dao layer

@Repository("permissionDao")
public interface PermissionDao extends IBaseDao<T_Permission, String>, IBaseBusinessQuery<T_Permission,String> {
}

dao layer After modification


@Repository("permissionDao")
public interface PermissionDao extends IBaseDao<T_Permission, String>, IBaseBusinessQuery<T_Permission,String> {

    @Override
    T_Permission findOne(String key);
}

mybatis mapping file

  <select id="findOne" resultType="T_Permission">
        select * from t_permission where `ps_id` = #{key}
    </select>

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 6,464 milliseconds ago. The last packet sent successfully to the server was 22 milliseconds ago.



Solution 1:[1]

The database version maybe have the influence. For me, when mysql version is 5.1.14, the error is like yours. But I change the mysql verison to 8.0.17, and all the problems solved!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justin Shi