0

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.

suncsf
  • 1
  • 1
  • 2
    This sounds like an issue between your server and your database instead of a code issue. The exception is not even from the mybatis library its from the underlying jdbc lib. – Deadron Jul 15 '19 at 05:50
  • Refer to [this](https://stackoverflow.com/questions/2983248/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai) – Mansur Jul 15 '19 at 06:01
  • @Deadron, You are right,my database is MariaDB,but,the driver file is mysql's, driver-class-name: com.mysql.jdbc.Driver -> org.mariadb.jdbc.Driver,but,I'm confused, I used to use it no problem. – suncsf Jul 15 '19 at 07:16
  • Please post the full exception stacktrace. The error with a non-zero 'milliseconds ago' usually means that the connection broke for some reason (network problem/disconnect, connection lifetime exceeded on database server or other things that break the TCP/IP connection between the JDBC driver and the server). However using the MySQL driver with MariaDB could prossibly result in problems as well because although MariaDB was forked from MySQL, they are no longer the same. – Mark Rotteveel Jul 15 '19 at 09:43

1 Answers1

0

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!

Justin Shi
  • 33
  • 6