Managing transactions which run accross multiple java beans.

Discussions

Web tier: servlets, JSP, Web frameworks: Managing transactions which run accross multiple java beans.

  1. I am using java beans (NOT EJB) to implement business logic in an application where each bean gets a connection from a connection pool.
      In such a case how do I handle transactions which run across multiple beans cause as far as I understand transactions are handled by setting autocommit to false for the connection used and then committing when all work is done but in my case each bean gets an individual connection from the pool.

    If someone can help me out here it will be very much appretiated.
  2. Harikrishna, maybe you need to turn your applications logic 'inside-out'. Why not get your connection first, shutting off autocommit, then pass the connection to each bean that needs it? If you're doing this across multiple JSPs or Servlets, you'd need to get the connection, store it in the session, and pick it up to pass to each bean as needed. You'll need something to trigger the commit/rollback (e.g., user presses SUBMIT).