personnaly i used informations from here
http://cwiki.apache.org/CAY/setting-database-connection.html
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
OpconPoolManager.getConnection().close();
_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.
>
This archive was generated by hypermail 2.0.0 : Mon Mar 31 2008 - 14:14:46 EDT