AtomHeartFather
AtomHeartFather

Reputation: 957

How to limit number of connections to a database in spring?

I have a Spring based application, deployed on the Tomcat server. What I need is to limit the maximum number of simultaneous connections to a database. This is data source section from my applicationContext.xml:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="org.postgresql.Driver" />
  <property name="url" value="..." />
  <property name="username" value="..." />
  <property name="password" value="..." />
</bean>

I would like to do it on the application level, not with server configuration.

Upvotes: 1

Views: 1601

Answers (1)

Chris
Chris

Reputation: 23179

Set the maxActive property on the dataSource.

Upvotes: 9

Related Questions