简体   繁体   English

C3P0连接问题

[英]C3P0 Connection Problem

I am using hibernate and cp30 for database operations and getting error: 我使用的数据库操作和获取错误Hibernate和CP30:

com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection

Here are my jdbc properties: 这是我的jdbc属性:

    <property name="acquireIncrement" value="2"/>
    <property name="initialPoolSize" value="6"/>
    <property name="maxIdleTime" value="21600"/>
    <property name="maxPoolSize" value="10"/>
    <property name="maxStatements" value="0"/>
    <property name="minPoolSize" value="2"/>
    <property name="idleConnectionTestPeriod" value="10800"/>
    <!--<property name="testConnectionOnCheckout" value="true" / >-->
    <property name="preferredTestQuery" value="SELECT NOW()"/>
    <property name="maxAdministrativeTaskTime" value="3590"/>
    <property name="unreturnedConnectionTimeout" value="3595"/>
    <property name="debugUnreturnedConnectionStackTraces" value="true"/>

and cp30: 和cp30:

 <prop key="c3p0.acquire_increment">3</prop>
 <prop key="c3p0.idle_test_period">300</prop>
 <prop key="c3p0.max_size">15</prop>
 <prop key="c3p0.max_statements">0</prop>
 <prop key="c3p0.min_size">3</prop>
 <prop key="c3p0.timeout">5000</prop>

Mysql is not giving me any connection right now. Mysql现在没有给我任何连接。 Is there any way to display the connection usage of mysql? 有什么方法可以显示mysql的连接用法? And can i flush these bad connections? 我可以冲洗这些不良的连接吗? And the most important question is, what should i do to avoid this connection pool error? 最重要的问题是,我应该怎么做才能避免此连接池错误?

Thanks in advance. 提前致谢。

Datasource is 数据源为

<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />

        <!--<property name="connectionCustomizerClassName" value="org.xxx.webapp.common.persistence.WatchConnectionCustomizer"/>-->
    <property name="maxStatements" value="500"/>
    <property name="maxIdleTime" value="1800"/>
    <property name="maxPoolSize" value="100"/>
    <property name="minPoolSize" value="2"/>
    <property name="initialPoolSize" value="2"/>
    <property name="acquireIncrement" value="3"/>
    <property name="idleConnectionTestPeriod" value="3000"/>
    </bean>



<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>org.fbis.models.Form21</value>
                <value>org.fbis.models.GSCDetails</value>
                <value>org.fbis.models.DigitalRegistraion</value>                   
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>

    </bean>  

Add hibernate-c3p0-4.2.1.Final.jar 添加hibernate-c3p0-4.2.1.Final.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM