4 Replies Latest reply on Apr 13, 2005 12:21 PM by ebdr

    How to enlinst an external JDBC Connection to the current tr

    ebdr

      Hi,

      back ground: We are building an "application builder" application which will run in a ASP mode. Users can access there application via a web interface; and via an administration console, they can create any application (Business object creation, worklfow configuration, front end design, etc...) Each client application has one (or more) dedicated database (its table structure is created by the application builder).
      As a result of this architecture, the application builder has to manage N connection pools (one per databases it is connected to) which is managed (connect/disconnect, etc...) at runtime by the application builder. We therefore cannot use the JBoss connection pooling mechanism since its connection needs to be defined at deploy time.

      my question: given a Connection (or a DataSource) object, how can I enlist it in the current UserTransaction?

      I beleive I have 2 options:
      1. - in a stateless SessionBean get the Transaction: Transaction tx = (Transaction) ctx.lookup("java:/Transaction");
      - somehow wrap my Connection into an XAResource (I don't know how to do this)
      - enlist my XAResource to the current Transaction: tx.enlist(myXAResource);

      2. create a JCA Connector for the engine that manages the Connections. I am not very familiar with JCA and I am not sure it would solve my problem.

      A hidden question in this scenario is how do I handle cases where Databases does not support 2-phase commit or transaction all together.

      I really appreciate your help, pointers to resources and ideas in this matter.

      Best,
      -Eric

      P.S. we are currently using JBoss 3.2.0 + tomcat 4.1.24 + postgres 7.3 ( I know they are old releases but we will migrate later when we have more time :-))