> From: neven.cvetko...@gmail.com
> Date: Wed, 5 Mar 2014 20:25:36 -0500
> Subject: Re: understanding jdbc pool
> To: users@tomcat.apache.org
> 
> On Wed, Mar 5, 2014 at 3:15 PM, S Ahmed <sahmed1...@gmail.com> wrote:
> 
> > Hi,
> >
> > With jdbc pool, is each socket connection in the pool handled by a separate
> > thread?
> >
> >
> Ahmed, thanks for asking this question - it is sometimes very confusing
> with all different kind of pools: connection pools, threadpools, etc...
> 
> Chris pointed out already - the connection pool does not have any
> threads... It is not a process that runs in the background, these are just
> connection objects that are sitting in memory.
> 
> Threads are created by the Tomcat container (executor) once the connection
> is received by the Connector. The created thread is then going to be
> handled by the container and it will go through the stack call, through
> Valves, Filters, Servlets, your middleware layer, DAOs, JDBC/JPA calls and
> then finally through your datasource object, connection, PreparedStatement,
> ResultSet, etc... and back all the way to the socket that browser
> initiated, returning the thread to the threadpool (e.g. http-bio-8080).
> 
> Now, I am not sure about the connection pool implementation details, how
> connection pool keeps connections open, if there are any background threads
> that are handling connection management (closing abandoned connections,
> opening new connections as the demand rises, etc...)
> 
> Maybe someone can comment on that.
MG>Not from 1.4 commons-dbcp..here is a typical reference to Thread in source
MG>Thread.currentThread().
MG>(Although I have seen multiple thread calls in attached testcases) I have 
not seen Separate Thread in main body
MG>I am sure  someone here would put a feature request in to support 
Thread-Aware Connections
MG>If you put the feature request in I will second the request (and make sure 
ThreadAware gets implemented)
MG>Then again Im sure there are other libraries that will handle Thread aware 
database connection pools
MG>would anyone know the names of those libraries?
MG>BTW Mr Schultz is right
> 
> > Say you have 20 connections set to be open at minimum, does that mean there
> > will be 20 threads? If not, then there is a degree of serialization then
> > right?
> >
> 
> 
> Well, there will be no serialization, but rather "synchronization" as there
> are at most XXXX available connections, if the connection pool (datasource)
> reaches maximum allowed connections, depending on the implementation - it
> would be a blocking call, until the pool has available connection to
> provide...
> 
> Look at the documentation for Tomcat default connection pool implementation:
> https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
> 
> 
> Hopefully that clears some of the confusion.
> 
> 
> Cheers!
> Neven
                                          

Reply via email to