The connection handling mechanism in AS Java enables the sharing of a single physical connection between multiple users — that is, it supports multiple connection handles associated to a single physical connection. This feature is implemented for optimization purposes and is especially useful when the back-end system allows for establishing a limited number of connections.
For an example about connection sharing, refer to Configuring Transaction-Related JMS Connection Factory Propertie
Recommendation
We recommend that you use connection sharing.
Connection sharing is only possible for transactional resources, which are used in distributed transactions.
To use sharing, you must make sure that:
The connection is provided by a connection factory with either LocalTransaction or XATransaction support.
The resource reference is not declared nontransactional.
More information: Connection Handling in JTA and Local Transactions
To enable connection sharing, you must set the sharing scope parameter for the resource in the deployment descriptor of the relevant application component that uses the connection.
The sharing scope of a resource is either Shareable or Unshareable.
The following example is a part of the deployment descriptor of an enterprise bean. It defines a shareable resource.
Syntax
<resource-ref> <res-ref-name>jdbc/CAR_RENTAL_POOL</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref>