When you access a database from a J2EE application, the JNDI interface is used to request the search of the javax.sql.DataSource type objects (hereafter, DataSource objects). With the default J2EE server operations, when the applicable DataSource is registered, the instances of the DataSource object are generated and returned to the application.
At this time, if you use DataSource object caching, the J2EE server caches the instances of the registered DataSource object, and returns the same instances for a search request. If you use DataSource object caching, the search time for the DataSource objects is shortened.
You specify the settings for caching the DataSource objects by customizing the J2EE server properties. For details on customizing the settings for the J2EE server operations, see 3.14.10 Settings in the execution environment.
The DataSource object caching functionality is enabled when DataSource is looked up with the business method of the Enterprise Beans and the service method of the servlets/JSPs, and the relevant instance is not stored in the member variable.
The functionality is not enabled when the DataSource object looked up with the business method and service method is stored in the member variable and is also used with other methods. The functionality is also not enabled when the DataSource object looked up in the initialization methods such as the ejbCreate method of Enterprise Bean and the init method of servlets/JSPs is stored in the member variable and is used in the business method and service method.
If you use a resource adapter such as that described below when the DataSource object caching functionality is used, the <resource-ref> definition in the property file might not be enabled during operations:
To define multiple <resource-ref> tags with the same J2EE component, make sure you use another resource (resource adapter with a different deployment unit).