当前位置: 代码迷 >> J2EE >> An attempt by a client to checkout a Connection has timed out 急解决思路
  详细解决方案

An attempt by a client to checkout a Connection has timed out 急解决思路

热度:607   发布时间:2016-04-17 23:42:53.0
An attempt by a client to checkout a Connection has timed out 急、急、急、急、
数据库是Mysql的   
 在linux系统上 和mysql一台机器  
 启动会没访问多长时间就报:
 An attempt by a client to checkout a Connection has timed out  


 以下是applicationContext.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"  
xsi:schemaLocation="http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context  
http://www.springframework.org/schema/context/spring-context-2.5.xsd  
http://www.springframework.org/schema/aop  
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
http://www.springframework.org/schema/tx   
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
  
<!-- 自动搜索全包 -->   
<context:component-scan base-package="*"/>   

<!-- JMS配置-->  
  <!--import resource='jmsContext.xml' /--> 
  
  <!-- 加载数据库连接配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>

  <bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="${jdbc.driverClassName}" />
<!-- 指定连接数据库的URL -->
<property name="jdbcUrl" value="${jdbc.url}" />
<!-- 指定连接数据库的用户名 -->
<property name="user" value="${jdbc.username}" />
<!-- 指定连接数据库的密码 -->
<property name="password" value="${jdbc.password}" />

<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="60" />
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="2" />
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="5" />
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20" />
<!--当连接池连接耗尽时,客户端获取连接等待所需时间-->
<property name="checkoutTimeout" value="20000"/>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement" value="5"/>


</bean>

<!--定义了Hibernate的SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<!-- value>com.wificity.community.model.extend</value -->  
<value>com.businessserver.mercant.model</value>  
<value>com.businessserver.mercant.model.extend</value>  
<value>com.businessserver.game.model.extend</value>  
<value>com.businessserver.users.model</value>  
<value>com.businessserver.game.model</value>  
<value>com.businessserver.pay.model</value>  
<value>com.businessserver.users.model.extend</value>  
<value>com.businessserver.pay.model.extend</value>
<value>com.businessserver.manager.model</value>  
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.generate_statistics">false</prop>
<prop key="hibernate.jdbc.batch_size">30</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
</props>
</property>
</bean>

  

<!-- 事务管理器 -->  
  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  <property name="sessionFactory">  
  <ref bean="sessionFactory"/>  
  </property>  
  </bean>  

  <!-- 对标注@Transaction注解的Bean进行事务管理 -->  
  <tx:annotation-driven transaction-manager="transactionManager"/>  
    
  <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" >
<property name="sessionFactory"><ref bean="sessionFactory" /></property>
  相关解决方案