Subject | Re: problem with Connection-Pooling |
---|---|
Author | Roman Rokytskyy |
Post date | 2004-05-29T10:26:08Z |
> Than there is maybe a bug in my code that some connections are notMaybe. If you want to exclude our pool bug, configure your application
> closed.
to use Jakarta's DBCP (see wiki's configuration section).
> But I don't understand minsize and maxsize.Correct.
> I thougt maxsize is the number simultaneous connection i can use.
> (When i want to use more than maxsize connection simultaneous i will
> get the blocking error)
> And minsize is the number of connections that will remain open, evenminSize is number of connections that will not be closed after
> if i don't use minsize connections, is that right ?
idleTimeout. When your application returns all connections back to the
pool, connections are considered "idle". After the idleTimeout
background thread starts closing the connections until the number of
open connections reaches minSize.
> So why is FreeSize = 5 at startup with maxsize = 20 and minsize = 5,Free size tells how many already open connections are now in pool
> I would say it must be 20, because there are 20 connection i can
> take simultanous.
(equivalent to number of idle connections) ready to be returned to the
application. Consider following example:
- You start your pool, it opens 5 connections to the database. All
they are idle. freeSize = 5, because no connection was obtained by
application, workingSize = 0, totalSize = 5.
- Your application takes one connection. freeSize = 4, workingSize =
1, totalSize = 5.
- Your application takes next 4 connections. freeSize = 0 (no
available connection in pool), workingSize = 5, totalSize = 5.
- Your application takes one more connection. Pool checks that there
is no free connections, allocates one and returns it to the
application. freeSize = 0, workingSize = 6, totalSize = 6.
- Your application returns connections back to pool. freeSize = 1,
workingSize = 5, totalSize = 6.
- idleTimeout passes. Background thread checks the time when
connection was returned to pool, sees that it was idle long enough and
closes physical connection to the database. freeSize = 0, workingSize
= 5, totalSize = 5.
- Your application returns all connections to pool. freeSize = 5,
workingSize = 0, totalSize = 5.
As you see, totalSize is always equal to freeSize + workingSize.
Blocking happens only when totalSize = maxSize and application want
next connection. In theory, totalSize cannot be less than minSize
under any circumstances. If your application is idle enough and
returned all connections to pool, totalSize = minSize.
Hope this helps.
Roman