Start of Content Area

Procedure documentation Acquiring and Releasing a Connection  Locate the document in its SAP Library structure

Activities

...

       1.      If you need a current connection from the connection pool, you can acquire this, execute one or more function calls in the SAP server, and then return (release) the connection to the connection pool. The method getClient() is used to acquire a connection.

       2.      If all connections in a pool are assigned and the pool has reached its maximum size, SAP JCo waits for a defined period of time (default value: 30 seconds). If no connection becomes available within this time period, an Exception Message (JCO.Exception.JCO_ERROR_RESOURCE.) is output.

NoteTo change the default value for the wait time, you can use the method setMaxWaitTime(), which is available for PoolManagers as well as for individual JCO.Pool objects. The new value is transferred in milliseconds.

       3.      After a successful function call, the connection to the method releaseClient() is released back into the pool.

       4.      NoteThis normally happens in a finally block, so that the method is always executed, independently of whether or not an exception is output. Otherwise if the connection is not released, this could lead to a shortage of available connections in the connection pool.

 Syntax documentation

Requesting a Connection

 

mConnection = JCO.getClient (POOL_NAME);

 

 

Releasing a Connection

 

 

 

System.out.println (mConnection.getAttributes () );

}

 

catch (Exception ex)   {

   ex.printStackTrace ();

}

finally  {

   JCO.releaseClient (mConnection);

}

 

NoteFrom an SAP server perspective, a session begins with the call of getClient(), and ends with releaseClient(). If you want to call different RFMs in sequence without any third-party interaction occurring during this time, maintain the connection long enough for the sequence to be executed (each RFM is a separate dialog step in the SAP server).

NoteWhen calling a connection pool, never use the methods connect() or disconnect() from the class JCO.Client. For connection pools, the functions are executed by the PoolManager.

Further Information

For the complete example program for establishing a connection pool, see:

Example Program Connect2.

 

 

End of Content Area