3.15.6 Automatically closing the connections

The connection of a resource that is opened with the user program must be closed with the user program. With this functionality, the Web container and EJB container automatically close a connection if the user program cannot close the connection due to reasons such as the occurrence of an exception.

You can enable and disable the auto-close connection functionality based on the functionality. The following table describes the methods and switching of auto-close connection.

Table 3-59 Auto-close connection method and switching of the functionality

Auto-close methodSwitching between enable and disableRemarks
Web container-based auto-close connectionY#1, #2--
EJB container-based auto-close connectionN#1Always enabled.
Legend:
Y: Can be switched
N: Cannot be switched
--: Not applicable

#1: The target resource is the resource adapter connection.

#2: The Web container-based auto-close connection functionality is enabled by default. You specify the settings for disabling the functionality by customizing the J2EE server properties. For details on customizing the settings for the J2EE server operations, see 3.15.13 Settings in the execution environment.


Organization of this subsection
(1) Web container-based auto-close connection
(2) EJB container-based auto-close connection
(3) Method that confirms the execution of auto-close connection
(4) Notes

(1) Web container-based auto-close connection

From among the JDBC connections that are obtained or opened in the servlet and JSP service methods, the connections that are not closed when the method execution finishes are automatically closed by the J2EE container. Due to this, the connections that are open and accumulating can be closed automatically.

Note that the auto-close connection functionality is also enabled when the connections are obtained or used by other methods in a servlet, or by the external classes.

The Web container-based auto-close connection is executed when the servlet and JSP service methods are completed.

(2) EJB container-based auto-close connection

With this functionality, the EJB container automatically closes and releases a connection if the user cannot close a resource connection obtained in the EJB, due to reasons such as the occurrence of an exception.

The EJB container-based auto-close connection is implemented at the following times:

Note that auto-close connection is implemented at the following times with the Singleton Session Bean or Stateless Session Bean specifying the @Asynchronous annotation:

(3) Method that confirms the execution of auto-close connection

You can use the message log or PRF trace to confirm that the auto-close connection functionality was executed.

We recommend that you use the message log to confirm the execution of the functionality when the performance need not be considered, such as during testing and troubleshooting; and the PRF trace when you want to confirm the execution of the functionality during real operations.

(a) Method of confirming with the message log

Set the log level to Warning.

When auto-close connection is executed, KDJE31010-W is output to the J2EE server message log.

For details on how to set the log level, see 3.3.6 Settings for collecting the J2EE server log in the uCosminexus Application Server Maintenance and Migration Guide.

(b) Method of confirming with the PRF trace

Set the PRF trace collection level of the JCA container functionality layer to Detail.

When auto-close connection is executed, the following event IDs are output to the PRF trace file:

For details on how to set the PRF trace collection level, see 3.3.6 Settings for collecting the J2EE server log in the uCosminexus Application Server Maintenance and Migration Guide. Also, for details on how to set the PRF trace collection level for each functionality layer, see cprflevel (Displaying and changing the PRF trace collection level) or cprfstart (Starting the PRF daemon) in the uCosminexus Application Server Command Reference Guide.

(4) Notes