0

我在服务器端 spring bean 中使用 ExecutorService。我认为的问题是,当 ExecutorService 为池创建线程时,它还会从连接池(C3P0)中获取一个 DB 连接,然后不释放它,一段时间后连接超时。如果我启动我的服务器,那么一切都会正常运行一段时间,但是在周末之后,这里是个例外:

2012-07-09 11:12:10,825 ERROR [JDBCExceptionReporter] : The last packet successfully received from the server was259505 seconds ago.The last packet sent successfully to the server was 259505 seconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not execute query
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255)
    at za.co.bsg.ems.server.webservices.MWLWebServiceImpl.getUnpaidLeaveForms(ebff4f5 --------------:166)
    at za.co.bsg.ems.server.webservices.MWLWebServiceImpl.access$300(ebff4f5 --------------:37)
    at za.co.bsg.ems.server.webservices.MWLWebServiceImpl$2.run(ebff4f5 --------------:136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.loader.Loader.doList(Loader.java:2536)
    at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2319)
    at org.hibernate.loader.Loader.list(Loader.java:2268)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
    ... 6 more

为什么执行完成后我的线程没有释放连接?

4

0 回答 0