[Opensource] (no subject)

Suresh.M, ISDC Chennai sureshm at msdc.hcltech.com
Tue May 4 03:22:03 PDT 2004


Hi all..
 This is in response to the connection pooling problem mail(to be more clear
even after database server restart the application fails to get a connection
if the application server is not restarted)

Solution which I found successfull is...

   The scenario is that:
    The database server is not reporting to the application server when ever
its restarted(Actually its required to restart the application server
whenever you restart the database server)..So the connection pool handler in
our case the datasource, is not aware of the fact that the connections
inside the pool it is having is stale and needs to be re initialised.And
since the implementation of the connection pool is using a stack ,if we
return the bad connection it will put it over the top of the stack and will
return the same stale connection all the time and it will end up waiting
until the connection time out.

To get out of this problem we kept the bad connections with us and
forcefully requested for a new connection until we got a good connection
(using datasource.getConnection()) and when we get a good connection
(identified as good connection by running a test query using the connection
and checking for a non empty resultset before using it)we will give the bad
connections back to the stack(using connection.close()) and the application
server by itself will reinitialise the connection..
To summarize
  previously we were asking for a connection and using it straight
away(thats the normal practice).
  now we are asking for the connections and keeping the connection in an
array until we get a good connection 
  and will return the bad connections to the connection pool stack for the
application server to refresh the connection.

The algorithm for the function which fetches the connection from the pool.

while(badconnection){
   Get a Connection from the pool.
   Check for good connection by running a test query
   If its a good connection       
      return the connection for use       
   end if
   else
     keep the connection with us in an array.
     get a new connection
   end else 
 }





Thanks & Regards,

Mathew Suresh.
Associate Software Engineer,
I.S.D.C,
HCL Technology Solutions Ltd.,
34 & 35 Haddows Road,
Nungambakkom,
Chennai 600 034,India.
Phone:52159999
Extn:1512


Disclaimer:
This document is intended for transmission to the named recipient only. If
you are not that person you should note that legal rights reside in this
document and you are not authorized to access read disclose copy use or
otherwise deal with it and any such actions are prohibited and may be
unlawful. The views expressed in this document are not necessarily those of
HCL Technologies Ltd. Notice is hereby given that no representation contract
or other binding obligation shall be created by this e-mail which must be
interpreted accordingly. Any representations contractual rights or
obligations shall be separately communicated in writing and signed in the
original by a duly authorized officer of the relevant company.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20040504/e7fbe47f/attachment.htm


More information about the Opensource mailing list