Hi Bdm, I guess you should use connection pooling but if you want to manage your own connection I would do it like this:
Manage the JDBC connection as thread with per-request scope. I think the Connection is already an interface so you can do the following in APP Module: @Scope(ScopeConstants.PERTHREAD) public static Connection buildConnection( @Inject final PerthreadManager perthreadManager, ) { Connection con = // establish connection here perthreadManager.addThreadCleanupListener(new ThreadCleanupListener() { @Override public void threadDidCleanup() { try { con.close(); } catch (Throwable t) { } } }); return con; } Beware! As I understand it, this will create a connection for every single request which is okay for an App that get's very little use but will scale horribly. Close will be called at the end of the request. Of course you can access the connection by putting @Inject Private Connection con; in your components, pages or services. Hope this helps! Kind Regards, Wulf -----Original Message----- From: bdm [mailto:b...@imageau.eu] Sent: Montag, 28. November 2011 14:24 To: users@tapestry.apache.org Subject: tapestry, hibernate and timeout Hello, I have got a problem with a small crud app developed with tapestry. This is a low traffic application so it can be unused for more than one day before we need it again. The problem is we got a timeout with the jdbc connection and we need to restart the application container (Glassfish) to have the jdbc connection up again. It is getting boring ! :) It seems I missed something in the tapestry application logic ! Is there a solution to close the session when the application has finished a DB operation and open it only when needed ? Here is the stack trace: Thanks ! BDM. -- View this message in context: http://tapestry.1045711.n5.nabble.com/tapestry-hibernate-and-timeout-tp5028844p5028844.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org