Activiti5.12 + Mysql connection错误

本文探讨了在使用Activiti工作流引擎结合MySQL数据库时遇到的连接超时问题,详细分析了原因并提供了可能的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目使用的工作流引擎是Activiti 5.12,数据库是MySQL

背景:

前段时间项目挂到测试服务器上进行测试了,

结果后来每天早上项目重新打包后的第一次工作流提交操作,都会发生错误。

在项目的日志文件里面找到类似的这个错误:

### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 31,303,700 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.
### The error may exist in org/activiti/db/mapping/entity/Property.xml
### The error may involve org.activiti.engine.impl.persistence.entity.PropertyEntity.selectProperty-Inline
### The error occurred while setting parameters
### SQL: select * from ACT_GE_PROPERTY where NAME_ = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 31,303,700 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.

 已wait_timeout为关键字搜索,经过分析得到结论:

是由于Mysql服务器的wait_timeout 属性造成的,Mysql默认的“wait_timeout”是8小时(28800 second),也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection,但是在项目中的数据库连接现在是不知道这个连接是已经失效的,如果这时有客户端请求connection,并执行相应操作,将会造成上面的异常。

类似错误:http://forums.activiti.org/content/mysql-exception

不过好的是,在Activiti中可以使用连接池:

官网文档:http://activiti.org/userguide/index.html#databaseConfiguration

然后配置上相应的数据库连接属性,应该就好了。

不过具体的还有待我验证两天,如有问题,还望指出!

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值