问题描述:应用启动后,长时间不操作,再次操作报错,控制台输出
Cause: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
; SQL []; An I/O error occurred while sending to the backend.; nested exception is org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
问题分析:数据库连接失效,使用失效连接无法操作数据库
解决方法:添加验证sql,操作数据库前,如检测到连接已失效,则建立新的连接
jdbc.validationQuery=select 1 from dual
jdbc.testOnBorrow=true
jdbc.testWhileIdle=true
<property name="validationQuery" value="${jdbc.validationQuery}"/>
<property name="testOnBorrow" value="${jdbc.testOnBorrow}"></property>
<property name="testWhileIdle" value="${jdbc.testWhileIdle}"></property>