You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Sheng Huang <SH...@tlg.ca> on 2003/11/12 23:05:41 UTC

Should number of active connections plus idle connection equals t o number of connections?

Dear Sir or Madam,

I have DBCP configured as follows:
  		   <parameter>
    			<name>maxActive</name>
    			<value>4</value>
  		   </parameter>
  		   <parameter>
    			<name>maxIdle</name>
    		   	<value>4</value>
  		   </parameter>
  		   <parameter>
    			<name>maxWait</name>
    			<value>-1</value>
  		   </parameter>

And I have a testPool.jsp containing the following code:
    out.println("We have a connection pool and it has " +
connectionPool.getMaxActive() + " max active connections.<BR>");
    out.println("We have a connection pool and it has " +
connectionPool.getMaxIdle() + " max idle connections.<BR>");
    out.println("We have a connection pool and it has " +
connectionPool.getNumActive() + " active connections.<BR>");
    out.println("We have a connection pool and it has " +
connectionPool.getNumIdle() + " idle connections.");
However, after I started my application, I got 
We have a connection pool and it has 4 idle connections.
We have a connection pool and it has 4 idle connections.
We have a connection pool and it has 0 active connections.
We have a connection pool and it has 1 idle connections. 
Should getNumActive()+getNumIdle()=getMaxActive() since I set
maxActive=maxIdle? Is this an indication of connection leaking? Thank you
very much for your help.

Best regards,
Sheng

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


[dbcp] Should number of active connections plus idle connection equals t o number of connections?

Posted by Rodney Waldhoff <rw...@apache.org>.
(prefixing [dbcp] to the subject line to make sure it catches the eye
of the right folks)

I think the answer to your question is no.

getNumActive will return the number of connections you have borrowed but
not yet returned.

getMaxActive will return the maximum number of connections you should be
able to borrow at the same time.

In other words, it should be the case that getNumActive() <=
getMaxActive() at all times

getNumIdle will return the number of connections sitting idle in the pool,
ready to be borrowed.

It is possible to borrow connections when getNumIdle is 0, it just means a
new connection will need to be created.

getMaxIdle will return the maximum number of connections that can be idle
in the pool at any time.

If you return (close) a connection when
getNumIdle() == getMaxIdle(), then an idle connection will be discarded.

As with num/maxActive, it should always be the case that getNumIdle() <=
getMaxIdle() at all times.

On Wed, 12 Nov 2003, Sheng Huang wrote:

> Dear Sir or Madam,
>
> I have DBCP configured as follows:
>   		   <parameter>
>     			<name>maxActive</name>
>     			<value>4</value>
>   		   </parameter>
>   		   <parameter>
>     			<name>maxIdle</name>
>     		   	<value>4</value>
>   		   </parameter>
>   		   <parameter>
>     			<name>maxWait</name>
>     			<value>-1</value>
>   		   </parameter>
>
> And I have a testPool.jsp containing the following code:
>     out.println("We have a connection pool and it has " +
> connectionPool.getMaxActive() + " max active connections.<BR>");
>     out.println("We have a connection pool and it has " +
> connectionPool.getMaxIdle() + " max idle connections.<BR>");
>     out.println("We have a connection pool and it has " +
> connectionPool.getNumActive() + " active connections.<BR>");
>     out.println("We have a connection pool and it has " +
> connectionPool.getNumIdle() + " idle connections.");
> However, after I started my application, I got
> We have a connection pool and it has 4 idle connections.
> We have a connection pool and it has 4 idle connections.
> We have a connection pool and it has 0 active connections.
> We have a connection pool and it has 1 idle connections.
> Should getNumActive()+getNumIdle()=getMaxActive() since I set
> maxActive=maxIdle? Is this an indication of connection leaking? Thank you
> very much for your help.
>
> Best regards,
> Sheng
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

-- 
- Rod <http://radio.weblogs.com/0122027/>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org