Database sleeping and causing exception

前端 未结 1 1816
执笔经年
执笔经年 2021-01-06 04:56

When I don\'t make any database queries for some time I think it must sleep - if you then call it an exception is thrown;

java.sql.SQLNonTransientConnectionE         


        
相关标签:
1条回答
  • 2021-01-06 05:43

    This may be stretching your memory but could

    for some time

    have been 8+ hours? If so, likely to be the MySQL inactivity timeout, which disconnects after 28800 seconds. I hit this problem recently and found a few SO questions about it - this answer contained the best simple nuggets for solving the problem. In short, would suggest adding a validationQuery of SELECT 1 and setting testOnBorrow = true in the DBCP connection pool properties.

    0 讨论(0)
提交回复
热议问题