db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neuro <ne...@kart.edu.ua>
Subject Torque.shutdown() does not close underlying database connections.
Date Mon, 16 Dec 2002 13:46:42 GMT
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:
    public static void shutdown()
        if (dbMaps != null)
        if (dsFactoryMap != null)
            Iterator factorys = dsFactoryMap.values().iterator();
            while (factorys.hasNext())
                DataSourceFactory factory = (DataSourceFactory) factorys.next();
And extend DataSourceFactory from single
    void initialize(Configuration configuration) throws TorqueException;
    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

View raw message