I'm not an expert, but it seems like kind of a weird problem. Normally, the connections aren't left open -- they are only open for the length of time to commit a change. Maybe one is left open for reading -- I don't remember.
This would be how you tell the PoolManager to close everything, though. I don't remember how you get a hook to it, but I've done it in the past: http://cayenne.apache.org/doc/api/org/apache/cayenne/conn/PoolManager.html#dispose%28%29 I think perhaps you call DataNode.getDataSource() and typecast it to PoolManager. Here's some other threads that might be helpful (or may be red herrings) If I recall, in this particular case, the connections issue was a bug in the MySQL driver version. http://cayenne.195.n3.nabble.com/Cayenne-Connection-Pool-Monitoring-to-solve-out-of-connections-error-td812652.html On Tue, Sep 21, 2010 at 3:03 PM, <b...@holos.pt> wrote: > Hey Michael and Robert, > > Ok so i got the difference between context and connection. So how can i > close all connections before closing an application, a servlet or a > portlet? My main problem here is that on each deploy of a new web > application the connections from former deployments stay on (like memory > leaks), and i need to close them or at least use one pool for the whole > site. > > I was thinking about putting the Context on the HTTPSession of the > application server or making a context that is used permanently by the > server... Any ideas how to do it on liferay or tomcat? > > Thank you > Bruno > >> Hi Bruno, >> >> The Child DataContext *might* share the same database connection as >> the Parent DataContext. In general, you don't care about this, >> though. The DataContext, on commitChanges(), will request a database >> connection, use that connection for performing the commit, then return >> the connection back to the pool. It isn't required that the same >> database connection be used between a performQuery() and a >> commitChanges(). >> >> If you do commitChanges() on a Child DataContext, it pushes the >> changes to the Parent DataContext and to the database. If you only >> want the changes to go to the Parent DataContext and *not* the >> database, use commitChangesToParent(). >> >> mrg >> >> >> On Tue, Sep 21, 2010 at 2:22 PM, <b...@holos.pt> wrote: >>> Hello all, >>> >>> Do Child Contexts share the connection of a parent connection? When i do >>> a >>> commitChanges on the child the change is made on the database or in the >>> parent? I have already read the Nested Contexts page on the User Guide >>> but >>> this detail was confusing for me. >>> >>> Thank you >>> Bruno >>> >>> >> > > >