Start of Content Area

Procedure documentation Connection Pools  Locate the document in its SAP Library structure

Use

If you use generic user names to log on to the SAP server (which is normally the case for Web server applications), it is advisable to use connection pools, because all connections in a pool contain the same system, user, and client information. Connection Pools have two distinct advantages compared with direct connections:

         You avoid overhead in the SAP application because the connection remains open and can be reused as soon as one successful logon has taken place.

         You can restrict the maximum number of concurrent logons and thus avoid consuming too many SAP system resources.

NoteSelect an appropriate maximum number of concurrent logons to avoid user wait times result.

NoteOptimal use of connection pools is achieved if all pools use the same user ID. However, because the authorizations in SAP are linked to the user, this situation is only realistic if certain prerequisites are fulfilled (for example, if no security-relevant areas are affected).

 

The example coding below lists the connection attributes exactly as in the section Direct Connections , except that in this case, connection pools are used. For the complete example program for establishing a connection pool, see:

         Example Program Connect2.

Activities

...

       1.      First, you need the following specific classes:

        JCO.Pool: This class represents a connection pool

        JCO.PoolManager: All connection pools within a Java Virtual Machine (JVM) are administrated here.

       2.      Choose a pool name. In SAP JCo, you can use pool names of your choice. However, because pools are valid globally within a JVM, you should use a specific naming standard if different applications are running on the same JVM.

       3.      The global JCO.PoolManager object administrates all pools and can be called using the method getClientPoolManager() of the class JCO. The method getPool() attempts to call a particular pool (name). If no pool exists with the specified name (return value null), a new pool is created.

Syntax documentation
Classes

 

 

JCO.Pool

JCO.PoolManager

Defining a Pool Name

 

static final String POOL_NAME = “Pool“;

 

Does the pool exist already?

 

JCO.Pool pool = JCO.getClientPoolManager ().getPool (POOL_NAME);

if (pool == null)   {

 

 

Further Information

For information on further procedures, see:

         Creating a Connection Pool

         Acquiring and Releasing a Connection

The complete example program for creating a connection pool:

         Example Program Connect2

 

 

 

End of Content Area