Java ExecutorService JDBC连接超时

时间:2012-07-09 09:39:33

标签: java jdbc connection executorservice

我在服务器端spring bean中使用了ExecutorService。我认为的问题是,当ExecutorService为池创建线程时,它还会从连接池(C3P0)获取数据库连接,然后不释放它,一段时间后连接超时。如果我启动我的服务器然后所有工作都游泳了一段时间,但是在周末之后这里是例外:

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

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

0 个答案:

没有答案