An attempt by a client to checkout a Connection has timed out
查了好多资料,还是找不到原因呀!!!
有人说去掉<property name="checkoutTimeout" value="18000" />,其实等于没做一样,无非是不报异常了,该连接不上还是连接不上!
也有人说<property name="maxPoolSize" value="1200"/>把这个改大一些,你看我这1200不小了吧!
还有人说<property name="acquireIncrement" value="10"/>把这个改成5,默认是3,我都改成10了,也够了吧!
我是tomcat集群配置,两个项目的spring配置文件一模一样,但是只有其中的一个经常报此异常!
怎么解决呀???运动会口号
2011-11-23 10:41:59 org.hibernate.util.JDBCExceptionReporter logExceptions 警告: SQL Error: 0, SQLState: null 2011-11-23 10:41:59 org.hibernate.util.JDBCExceptionReporter logExceptions 严重: An attempt by a client to checkout a Connection has timed out. 2011-11-23 10:41:59 org.hibernate.util.JDBCExceptionReporter logExceptions 警告: SQL Error: 0, SQLState: null 2011-11-23 10:41:59 org.hibernate.util.JDBCExceptionReporter logExceptions 严重: An attempt by a client to checkout a Connection has timed out. 2011-11-23 10:41:59 org.hibernate.event.def.DefaultLoadEventListener onLoad 信息: Error performing load command org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1596) at org.hibernate.loader.Loader.doQuery(Loader.java:717) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270) at org.hibernate.loader.Loader.loadEntity(Loader.java:1933) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:997) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:990) at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:531) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:525) at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:519) at com.ks.dao.ClassDAO.findByIdString(ClassDAO.java:322) at com.ks.service.CommonService.findByIdString(CommonService.java:99) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy43.findByIdString(Unknown Source) at com.ks.interceptor.FormTemplateInterceptor.intercept(FormTemplateInterceptor
<property name="checkoutTimeout" value="18000" />
这个属性是:如果获取新的连接是,连接池没有空闲的连接,则会等待,等待超过了18000毫秒,仍然没有获取到可用连接,则抛出以上的异常。
maxPoolSize这个最大连接数已经1200了,不可能并发有1200个连接
检查一下是不是哪里忘记关闭连接了 如果用户不是很多的话,一般就是程序问题
1.忘记关闭连接
2.出现异常忘记关闭连接
之前是jdbc.minPoolSize=2,后来改成jdbc.minPoolSize=20就好了。