---
title: "How to limit active database connections"
canonical: "https://support.appfire.com/space/SUPPORT/89133381/How%20to%20limit%20active%20database%20connections"
format: markdown
---
## <span style="color: #000000">Data source profiles</span>

<span style="color: #000000">With</span> [release 7.0](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74318178)<span style="color: #000000">, a new parameter is available on</span> [data source profiles](https://appfire.atlassian.net/wiki/spaces/SQL/pages/74321547/Configure+Data+Source+Profiles+-+10.x) <span style="color: #000000">called </span>*<span style="color: #000000">maxActive</span>*<span style="color: #000000"> which can be used to limit the number of actively executing SQL queries for a specific data source. Once the maximum active limit is reached, the next requested render of a </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macro using the specific data source returns an error message instead of trying to connect to the database. The message is something like:</span>

> Unable to process your request at this time. Try again later. The connection limit was reached for this data source.

<span style="color: #000000">This gives administrators a way to help manage database connections. This provides control over data source profiles similar to what is available for application server based data sources configured in </span>*<span style="color: #000000">server.xml</span>*<span style="color: #000000">.</span>

## <span style="color: #000000">Application server based data sources</span>

<span style="color: #000000">Application server based data sources have various management parameters including </span>*<span style="color: #000000">maxActive</span>*<span style="color: #000000"> and </span>*<span style="color: #000000">maxWait</span>*<span style="color: #000000">. See</span> [Tomcat JDBC Connection Pool](http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html)<span style="color: #000000">.</span>

<span style="color: #000000">If you need to further limit the number of connections used by </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macros, then you can use </span>*<span style="color: #000000">maxActive</span>*<span style="color: #000000"> data source profile setting to also control the application data source by referencing the application data source in the data source profile. For example, if </span>*<span style="color: #000000">myDS</span>*<span style="color: #000000"> is an application defined data source, then the following data source profile would further restrict </span>*<span style="color: #000000">SQL</span>*<span style="color: #000000"> macro connections:</span>

| <span style="color: #000000">**Name**</span> | <span style="color: #000000">**Value**</span> |
| --- | --- |
| <span style="color: #000000">myDS</span> | <span style="color: #000000">*dataSource=myDS | maxActive = 10*</span> |