Entering content frame

Procedure documentation Releasing a JCO Client Locate the document in its SAP Library structure

After a JCO Client has been used for a backend call it should be returned to the pool by calling the release() method. The release() method invokes the reset() method before the JCO client is returned to the pool.

The release() method is available with JCO Version 2 and higher and with R/3 Release 4.0 and higher. In older versions, the JCO client is disconnected and connected again but not reset.

Example: Releasing a JCo Client

public void doContent (IPortalComponentRequest request, IPortalComponentResponse response)
{
    IJCOClientService clientService = (IJCOClientService)request.getService(IJCOClientService.KEY);
    IJCOClientPoolEntry poolEntry;
    try
    {
        poolEntry = clientService.getJCOClientPoolEntry("SAP_PLM", request);
    }
    catch 
    {
        response.write("Currently no connection available. Please try again.");
        return;
    }
    JCO.Client client;
    client = poolEntry.getClient();
    client.execute("myFunction"); // example call
    // process the result of the call
    poolEntry.release();
}

Deleting a JCo Client

Use the delete() method if you want to disconnect the JCO client but not return it to the pool, for example, when the execution of the JCO produced an exception.

Example: Deleting a JCo Client

public void doContent (IPortalComponentRequest request, IPortalComponentResponse response)
{
    IJCOClientService clientService = (IJCOClientService)request.getService(IJCOClientService.KEY);
    IJCOClientPoolEntry poolEntry;
    try
    {
        poolEntry = clientService.getJCOClientPoolEntry("SAP_PLM", request);
    }
    catch 
    {
        response.write("Currently no connection available. Please try again.");
        return;
    }
    JCO.Client client;
    client = poolEntry.getClient();
    try
    {
        client.execute("myFunction"); // example call
    }
    catch (JCO.Exception e)
    {
        // Inform the user about the problem, e.g.
        response.write("Error in execution: " + e);
        poolEntry.delete();
        return;
    }
    // Normal case, process the result of the call
    poolEntry.release();
}

See also chapter Recommendations for JCO Clients for details about releasing JCO clients.

Leaving content frame