文档

Quick BI中数据集基于MySQL数据源生成,图表加载数据报“Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server”错

更新时间:
一键部署

问题描述

Quick BI中创建MySQL数据源,测试连接。或者,基于MySQL创建的报表访问时,图表加载数据报“The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server”。完整的异常信息如下:

2021-11-09 17:14:48 [INFO] initialize job context, jobHistoryId:071c20af-0988-4ee9-9092-dc70fbb6e5f5
2021-11-09 17:14:48 [INFO] start execute job.
2021-11-09 17:14:48 [INFO] sync begin. datasetId-[caf1dcda-1c71-424f-89d2-63f2a6fecd88] syncId-[7ea94cf9056e4a68b0a5f7f19142115a]
2021-11-09 17:15:18 [INFO] check rows.
2021-11-09 17:15:18 [INFO] current data rows:0
2021-11-09 17:15:33 [ERROR] sync error.Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2021-11-09 17:15:33 [ERROR] execute job failure.

问题原因

该问题是因为MySQL服务在长时间不连接之后断开了,断开之后的首次请求会抛出这个异常。

解决方案

1.在MySQL下的my.ini文件(在MySQL安装路径下)中添加配置。

具体解释如下:MySQL默认的“wait_timeout”是8小时(也就是默认的值默认是28800秒),也就是说一个connection空闲超过8个小时,MySQL将自动断开该connection。wait timeout的值可以设定,但最多只能是2147483,也就是约24天,不能再大了。

2.如果MySQL数据源是5.0之前的版本,可以在数据库连接的URL上加autoReconnect=true。即打开自动重连的开关,jdbc:mysql://localhost:3306/nd?autoReconnect=true

由于Quick BI中创建MySQL数据源时,无法主动配置URL,因此该方式只能联系数据库侧的支持人员或者dba进行修改,并重启MySQL服务。

适用于

  • Quick BI
  • 本页导读
文档反馈