. Who is the 'it' here? Is it the EJB container?So it will keep the used connection aside and will reuse it
That doesn't seem right.
If the same connection is needed back by the container for some other database operations within the same EJB method, then why would the conainer need to take an extra step of 'keeping the connection aside', because the connection as such is already in used/locked state.
If the same connection is needed back by the container for some other database operations within the same EJB method, then why would the conainer need to take an extra step of 'keeping the connection aside', because the connection as such is already in used/locked state.
.connection is used in a transaction and probably return the same connection object for your next call for getConnection() in dao2
With an EJB architecture, it is common for multiple EJBs that are doing database work to be invoked as part of a single transaction. Without XA, the only way for this to work is if all transaction participants use the exact same database connection. When you enable global transactions and select either Logging Last Resource or Emulate Two-Phase Commit, WebLogic Server internally uses the JTS driver to make sure all EJBs use the same database connection within the same transaction context without requiring you to explicitly pass the connection from EJB to EJB.
If multiple EJBs are participating in a transaction and you do not use an XA JDBC driver for database connections, configure a Data Source with the following options:
Supports Global Transactions selected
Logging Last Resource or Emulate Two-Phase Commit selected
This configuration will force the JTS driver to internally use the same database connection for all database work within the same transaction.
ramprasad madathil wrote:
> close() on the connection returns the connection to the pool. Once the connection is returned to the pool, it's in a ready to use state. Any (waiting/subsequent) requests to the datasource for a connection can end up using this ready to use connection.
I think that depends on whether the connection is in the scope of a transaction. It further depends on whether the tx is XA or non-XA.
in the Weblogic's description the bold text came with a precondition too that it needs certain Weblogic configuration params to be set.
So it means your design/code has to know what App server its going to be
To answer the pool giving always the same connection, if the spec lays out that connection pool should always give the same connection, and hence it cannot be given to others when not in use between the DAOs of the same EJB and hence its not worth spending time in closing it and reopening it and hence questions the DAO pattern.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |