哪种方法正确。春季休眠c3p0池?

时间:2018-09-07 21:57:57

标签: spring hibernate c3p0

我的spring + hibernate + c3p0 xml看起来像;

    <bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass">
        <value>${jdbc.driver.className}</value>
    </property>
    <property name="jdbcUrl">
        <value>${jdbc.url}</value>
    </property>
    <property name="user">
        <value>${jdbc.username}</value>
    </property>
    <property name="password">
        <value>${jdbc.password}</value>
    </property>
    <property name="initialPoolSize" value="5"/>
    <property name="acquireIncrement" value="10"/>
    <property name="acquireRetryAttempts" value="0"/>
</bean>
<bean id="defaultSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="myDataSource" />
    <property name="annotatedClasses">
        <list>
            <value>...</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.autoReconnect">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.c3p0.minPoolSize">30</prop>
            <prop key="hibernate.c3p0.maxPoolSize">100</prop>
            <prop key="hibernate.c3p0.timeout">600</prop>
            <prop key="hibernate.c3p0.max_statement">50</prop>
        </props>
    </property>
</bean>

我想知道最小,最大池大小应该写在数据源/会话工厂中吗?

我正在测试1000个并发用户的负载。

使用上面的代码,我的最大池大小从未超过15(默认为c3p0)。如果我在数据源中移动最大池,则池会增加,但响应速度会降低20-30%

有什么建议吗?

0 个答案:

没有答案