[dbcp] meanings of active, idle

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[dbcp] meanings of active, idle

mark archur
Hi,
I am using commons-dbcp and its going well so far. But, I am not 100% clear of what exactly an active, idle connection mean (and not sure if its meaning changes in the context of pool). Let me tell what I understand:
Active: A connection is said to be active if a connection is open and is not closed yet. In the context of pool, does the meaning change?
Idle: I am guessing a connection to be idle should be closed. But, not sure when can it be idle. Again, does the meaning change in the context of pool?
 
Thanks.

               
---------------------------------
Yahoo! Mail Mobile
 Take Yahoo! Mail with you! Check email on your mobile phone.
Reply | Threaded
Open this post in threaded view
|

Re: [dbcp] meanings of active, idle

Dirk Verbeeck
A connection is active when it is being used by the program. It was
borrowed from the pool by db.getConnection() and hasn't been returned to
the pool yet by con.close().
When a connection has been returned to the pool by con.close() then a
connection is considered idle.

A connection that is reallyClosed (the plysical connection to the
database), isn't in the statistics anymore. A connection will really be
closed by the pool if the maxIdle limit is reached and in other similar
cases. Normally the program using the pool just borrows/returns
connection frm/to the pool.

-- Dirk

mark archur wrote:
> Hi,
> I am using commons-dbcp and its going well so far. But, I am not 100% clear of what exactly an active, idle connection mean (and not sure if its meaning changes in the context of pool). Let me tell what I understand:
> Active: A connection is said to be active if a connection is open and is not closed yet. In the context of pool, does the meaning change?
> Idle: I am guessing a connection to be idle should be closed. But, not sure when can it be idle. Again, does the meaning change in the context of pool?
>  
> Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [dbcp] meanings of active, idle

mark archur

Dirk/All,

Thanks for the reply.

Your definition of "Active" (and also "Idle") looks convincing to me, but my tests do not prove the same. We know that there is a parameter called ?initialSize? introduced in version 1.2. I set initialSize to 12. In my program, when I print getNumActive(), it gives me a value 12.

If I understand the meaning of initialSize, it should JUST create connections in the pool and the connection should not yet be open (active) right?? The fact that it getNumActive() gave me value 12, does it mean it has 12 active connections(connections which are open by the program)?

AND, when I call basicDataSource.getConnection(), it returns me a connection right. Now, before closing this connection, I called getNumActive(), it prints 13. Does this prove that having initialSize in the settings really creates 12 ACTIVE (open-but-not-yet-closed) connections?

 

FYI: I am creating the basicDataSource by invoking BasicDataSourceFactory.createDataSource(Properties) method. And I cache basicDataSource so I can reuse it.

 

Am I missing anything basic here.

 

Thanks,

 

Pramodh.


Dirk Verbeeck <[hidden email]> wrote:A connection is active when it is being used by the program. It was
borrowed from the pool by db.getConnection() and hasn't been returned to
the pool yet by con.close().
When a connection has been returned to the pool by con.close() then a
connection is considered idle.

A connection that is reallyClosed (the plysical connection to the
database), isn't in the statistics anymore. A connection will really be
closed by the pool if the maxIdle limit is reached and in other similar
cases. Normally the program using the pool just borrows/returns
connection frm/to the pool.

-- Dirk

mark archur wrote:
> Hi,
> I am using commons-dbcp and its going well so far. But, I am not 100% clear of what exactly an active, idle connection mean (and not sure if its meaning changes in the context of pool). Let me tell what I understand:
> Active: A connection is said to be active if a connection is open and is not closed yet. In the context of pool, does the meaning change?
> Idle: I am guessing a connection to be idle should be closed. But, not sure when can it be idle. Again, does the meaning change in the context of pool?
>
> Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
Reply | Threaded
Open this post in threaded view
|

Re: [dbcp] meanings of active, idle

Dirk Verbeeck
Strange, there is a junit test doing the test you describe:
http://jakarta.apache.org/commons/dbcp/xref-test/org/apache/commons/dbcp/TestBasicDataSource.html#218
and it works for me.

Can you post your test?

Tnx
Dirk

mark archur wrote:

> Dirk/All,
>
> Thanks for the reply.
>
> Your definition of "Active" (and also "Idle") looks convincing to me, but my tests do not prove the same. We know that there is a parameter called ?initialSize? introduced in version 1.2. I set initialSize to 12. In my program, when I print getNumActive(), it gives me a value 12.
>
> If I understand the meaning of initialSize, it should JUST create connections in the pool and the connection should not yet be open (active) right?? The fact that it getNumActive() gave me value 12, does it mean it has 12 active connections(connections which are open by the program)?
>
> AND, when I call basicDataSource.getConnection(), it returns me a connection right. Now, before closing this connection, I called getNumActive(), it prints 13. Does this prove that having initialSize in the settings really creates 12 ACTIVE (open-but-not-yet-closed) connections?
>
>  
>
> FYI: I am creating the basicDataSource by invoking BasicDataSourceFactory.createDataSource(Properties) method. And I cache basicDataSource so I can reuse it.
>
>  
>
> Am I missing anything basic here.
>
>  
>
> Thanks,
>
>  
>
> Pramodh.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]