Section 11.3.3 of the spec shows an example of a session bean that uses a
couple database connections in a transaction.  The interesting thing about
this code is that the database connections are acquired before the
transaction is started:

    ...
    con1 = ds1.getConnection();
    stmt1 = con1.createStatement();
    ...
    con2 = ds2.getConnection();
    stmt2 = ds2.createStatement();
    ...
    ut.begin();
    stmt1.executeQuery(...);
    ...

With this coding style, when would the resources associated with the
connections get enlisted with the transaction manager and associated with
the transaction?  If the container interposes on the getConnection, it can
enlist the resources with the transaction manager, but can it do it before
the transaction is started?   Certainly, the JDBC driver isn't going to do
it in the Statement implementation.

Other than the above issue, I can see how you would want to code it as in
the example.  It moves the potentially time consuming connection code out of
the transaction.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to