Reputation: 27579
I have a webapp running with a Groovy console attached.
I have the following bean configured via XML:
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource">
<property name="driverClassName" value="${db.driverClass}"/>
<property name="url" value="${db.url}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
<property name="validationQuery" value="${db.validationQuery}" />
<property name="testOnBorrow" value="true" />
<property name="testWhileIdle" value="true" />
<property name="timeBetweenEvictionRunsMillis" value="1800000" />
<property name="numTestsPerEvictionRun" value="8" />
<property name="removeAbandoned" value="true"/>
<property name="logAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="60"/>
<!--connection pooling props -->
<property name="maxActive" value="${db.maxActive}"/>
<property name="maxIdle" value="${db.maxIdle}"/>
<property name="maxAge" value="${db.maxAge}"/>
<property name="maxWait" value="${db.maxWait}"/>
<property name="initialSize" value="${db.initialSize}"/>
<property name="minIdle" value="${db.minIdle}"/>
</bean>
Via the Groovy console, I can easily call:
appCtx.getBean("dataSource").setMaxActive(someNumber);
where appCtx
is my Spring application context.
My question is, will this actually change the connection pool behaviour. All the links I've found seem to focus on initial configuration. I'm trying to modify configuration after the pool is established.
Upvotes: 2
Views: 1540
Reputation: 26
On inspection of org.apache.tomcat.jdbc.pool.ConnectionPool
, it looks like it is checking the maxActive
property when fetching a connection from the pool.
So I can't say I know from experience, but it looks like it should work to set this value at Runtime.
Upvotes: 1
Reputation: 86
I couldn't find anything in the documentation either, but from looking at the implementation I'm pretty sure it's not intended to support modification after initialization for the following reasons:
Upvotes: 2