Show TOC Start of Content Area

Procedure documentation Sharing Connections  Locate the document in its SAP Library structure

Use

The connection handling mechanism in the J2EE Engine 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.

Recommendation

We recommend that you use connection sharing.

Prerequisites

Connection sharing is only possible for transactional resources, which are used in distributed transactions. In addition, resources cannot be shared in system threads.

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 non-transactional. For more information, see Connection Handling in JTA and Local Transactions.

Procedure

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.

Example

<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>

 

 

End of Content Area