On Sat, Sep 3, 2011 at 1:29 AM, Chris Hostetter <hossman_luc...@fucit.org>wrote:

>
> : I am not sure if current version has this, but  DIH used to reload
> : connections after some idle time
> :
> : if (currTime - connLastUsed > CONN_TIME_OUT) {
> :                       synchronized (this) {
> :                               Connection tmpConn = factory.call();
> :                               closeConnection();
> :                               connLastUsed = System.currentTimeMillis();
> :                               return conn = tmpConn;
> :                       }
> :
> :
> : Where CONN_TIME_OUT = 10 seconds
>
> ...oh wow.  i saw the CONN_TIME_OUT constant but i thought (foolishly
> evidently) that CONN was "connect" as it a timeout on creating a
> connection, not a timeout on how long DIH is willing ot use a perfectly
> good connection.
>
> I honestly can't make heads or tails of why that code would exist.
>
> Noble? Shalin?  what's the point of throwing away a connection that's been
> in use for more then 10 seconds?
>
>
Hoss, as others have noted, DIH throws away connections which have been idle
for more than the timeout value (10 seconds). The jdbc standard way of
checking for a valid connection is not implemented or incorrectly
implemented by many drivers. So, either you can execute a query and get an
exception and try to determine if the exception was a case of an invalid
connection (which again is sometimes different from driver to driver) or
take the easy way out and throw away connections idle for more than 10
seconds, which is what we went for.

-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to