WAS v8.5 > Develop applications > Develop data access resources > Develop data access applications > Develop data access applications > Benefits of resource references > Requirements for setting data access isolation levels

Direct and indirect JNDI lookup methods for data sources

We can use a direct or indirect method for the JNDI name (such as jdbc/DataSource) to look up a data source.


Direct

When we use a JNDI name such as jdbc/myDatasource, the application server assigns default values to the resource reference data. An informational message resembling the following is logged to document the default values:

[10/5/07 11:40:38:468 CDT] 0000002e ConnectionFac W  
 J2CA0294W: Direct JNDI lookup of resource jdbc/myDatasource.
   The following default values are used:

[Resource-ref CMConfigData key items]   
res-auth:                 1 (APPLICATION)  
res-isolation-level:      0 (TRANSACTION_NONE)  
res-sharing-scope:        true (SHAREABLE)  
loginConfigurationName:   null  
loginConfigProperties:    null  

[Resource-ref non-key items]   
isCMP1_x:                 false (not CMP1.x)  
isJMS:                    false (not JMS) 
commitPriority            0  
Java EE Name:                not set  
Resource ref name:        not set  
isCMP:                    false (not set)

The first of these attributes, res-auth, dictates what type of authentication is done. This default setting says the component-managed authentication alias is used if we do not specify an activation specification or we do not specify the username and password on the getConnection call. It says the container-managed alias is not used.

The second of these settings, res-isolation-level, says the isolation level is set to the "default" settings. For an enterprise bean, we can set this in the EJB bean itself. For a servlet getting a connection, this results in the isolation level being Repeatable_Read. This is a fairly restrictive isolation level. This can lead to lowered performance, because application requests will lock more rows than with a less restrictive isolation level.

Finally, the res-sharing-scope is set to Shareable, meaning a Shareable connection is used. For some applications, a Shareable connection is fine. For others, in particular those servlets that get multiple connections within a single service() method, it is not.

To avoid any surprises that might accompany these settings, you should change the application to use an indirect JNDI name instead of the direct JNDI name, and you should create a resource reference.


Indirect

To use values that are different from the defaults, use an assembly tool to define your resource reference.

The resource reference can also be created in the EJB Deployment Descriptor (ejb-jar.xml), Web Deployment Descriptor (web.xml), or Application Client Deployment Descriptor (application-client.xml) editors using an assembly tool. After you define the resource reference, we can do an indirect JNDI lookup (using the java:comp/env context). Then the values for the resource reference properties that are defined in the resource reference are used and the J2CA0122I message no longer appears. Read the topic on creating a resource reference for more information.


Related concepts:

Development and assembly tools


Related


Develop applications that use JNDI
Create or changing a resource reference


Reference:

Connection factory JNDI name practices


+

Search Tips   |   Advanced Search