db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John McNally <jmcna...@collab.net>
Subject Re: Torque.shutdown() does not close underlying database connections.
Date Mon, 16 Dec 2002 16:27:24 GMT
Please add to scarab.werken.com.  And patches (cvs diff -u) would be
appreciated.

john mcnally

On Mon, 2002-12-16 at 05:46, neuro wrote:
> When using torque in my web-application I've noticed following:
> Than i use tomcat\manager to reload my web-app database connections "leak".
> 
> The reason was:
> Torque.shutdown() does not release any underlying database connections.
> 
> So I've dig into source and see that shutdown() does only release resources
> associated with DatabaseMaps(idBroker&etc.) but doesn't release
> any resources associated with DataSoucefFactorys (from dsFactoryMap
> in Torque sources). Pool implementations use threads so OPEN
> connections survive torque shutdown and application unloading. That's
> realy unpleasent.
> 
> To solve this we can add some code to Torque.shutdown:
> -------------Torque.java
>     public static void shutdown()
>     {
>         if (dbMaps != null)
>         {
>            ....
>         }
>     //NEW CODE BEGIN
>         if (dsFactoryMap != null)
>         {
>             Iterator factorys = dsFactoryMap.values().iterator();
>             while (factorys.hasNext())
>             {
>                 DataSourceFactory factory = (DataSourceFactory) factorys.next();
>                 factory.shutdown();
>             }
>         }
>     //NEW CODE END
>     }
> -------------
> And extend DataSourceFactory from single
>     void initialize(Configuration configuration) throws TorqueException;
> to
>     void shutdown();
> And add implementations to various implemantations :)
> 
> Since Torque relying on DBCP pools its enought to call pool.close();
> to close connections.
> 
> //regards, neuro
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:turbine-torque-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:turbine-torque-dev-help@jakarta.apache.org>



Mime
View raw message