Activiti5.12 + Mysql connection错误

项目使用的工作流引擎是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

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

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

 

 

你可能感兴趣的:(Connection)