Connection hangs after time of inactivity

前端 未结 5 967
耶瑟儿~
耶瑟儿~ 2020-12-31 18:21

In my application, Spring manages connection pool for database access. Hibernate uses these connections for its queries. At first glance, I have no problems with the pool: i

5条回答
  •  时光说笑
    2020-12-31 19:13

    I've had problems like this before when the database is on a seperate box and there's a firewall in between which is set to timeout idle connections.

    In some circumstances the firewall cuts off the connection in such a way that the JDBC end doesn't detect, and attempting to use it results in an indefinite block.

    In my case it was a custom connection pool which sent a test query down the connection before returning it from the pool. I configured this test query to have a timeout (using Statement.setQueryTimeout) so that it didn't block indefinitely.

提交回复
热议问题