cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent Marchal <>
Subject Re: How to propoerly close context db connection
Date Mon, 31 Mar 2008 18:14:11 GMT
personnaly i used informations from here
I inherit the cayenne PoolManager (code is attached) and when a 
disconnect occurs i use a thread to poll when
the connection becomes active with

        try {
            _log.trace("[DatabaseConnectionMonitor:run()] Try to get a 
connection from PoolManager.");
            //Get a connection and close it immediately
            _log.trace("[DatabaseConnectionMonitor:run()] Connection to 
database established !");
        } catch (SQLException e) {
            //Event Disconnected already sent so do nothing
            _log.trace("[DatabaseConnectionMonitor:run()] Cannot get a 
connection from database.");

Colin Bankier wrote:
> Hi,
> I can't seem to find any examples of how to properly close a database
> connection and clear any related cache.
> My app is using an embedded database, of which it can download a new version
> and overwrite the old one. 
> At the moment I try to clear any cache using context.getQueryCache().clear() 
> (context is my DataContext instance).
>  And then set the context to null (for want of anything better to do).
> The app then downloads and copies a new version of the database over the
> old, and connects using context = DataContext.createDataContext() etc etc.
> However - the data displayed STILL is the old data - until the app is
> shutdown and re-started when it correctly reads the new data.
> Any help on how to properly close the database connection would be greatly
> appreciated.
> Cheers,
> Colin Bankier.

View raw message