How to perform a DB cleanup operation upon shutdown in an EJB container?

For ejbs the approach would be same as what zwei has mentioned, but to add an initializaiton or cleanup ejb with a method having annotation PreDestroy.

It looks like this works: (EDIT: For some reason the previously posted answer did not work with JBoss5.1. This works. ) public class SomeServlet extends GenericServlet { public void destroy(){ InitialContext ctx = null; try{ ctx = new InitialContext(); DataSource ds = (DataSource)ctx. Lookup("java:/someDataSource"); doStuff(); }catch(Exception e){ log.

Error("Bad things happened",e); } finally{ try { ctx.close(); } catch (NamingException e) { e.printStackTrace(); } } }//destroy() }//class.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions