2

I have an Java Swing application which include a c3p0 library for manage connection pools. In its configuration I setted property c3p0.maxPoolSize=10 but it still creates more connections once a user logs in to the system.

c3p0.acquireIncrement=1
c3p0.minPoolSize=1
c3p0.maxPoolSize=10
c3p0.maxIdleTime=300

HOw can I control this behaviour?

Here is my Spring XML database config

<context:property-placeholder
    location="main/resources/properties/database.properties" />
<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}" />
    <!-- these are C3P0 properties -->
    <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
    <property name="minPoolSize" value="${c3p0.minPoolSize}" />
    <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
    <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
</bean>

The bean is generated Ok, but I can't control this event:when user logs in into the system c3p0 automatically opens three more connections. What we want is (1) "Tell" to c3p0 via XML config file that we want only db connection per user and (2) c3p0 please control the number of total database connections by setting the number of connections until 10...

Please if I'm not clear, please tell me.

4

1 に答える 1