Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop Data access resources > Develop data access applications > Develop data access applications


Resource reference benefits

WAS requires your code to reference application server resources (such as data sources or J2C connection factories) through logical names, rather than access the resources directly in the Java Naming and Directory Interface (JNDI) name space. These logical names are called resource references.

Application Server requires use of resource references for the following reasons:

Example of using a resource reference

The following code invokes a data source by creating a place holder for it through the lookup method. Using the logical name jdbc/Section, the code stores the place holder in the JNDI subcontext java:comp/env/; hence jdbc/Section becomes a resource reference. (The subcontext java:comp/env/ is the name space that WAS provides exclusively for object references within application code.)

javax.sql.DataSource specificDataSource  =
   (javax.sql.DataSource) (new InitialContext()).lookup("java:comp/env/jdbc/Section");
//The method InitialContext()).lookup creates the logical name, or resource reference, jdbc/Section.
Generally, an actual data source is configured later as an administrative task.

The logical name jdbc/Section is officially declared as a resource reference in the application deployment descriptor. You can then associate the resource reference with the JNDI name of the actual data source in several ways:

This act of association is called binding the resource reference to the data source.

See the article, Application bindings, for information on all types of required resource bindings.


Related


Requirements for setting data access isolation levels
Data sources
Application bindings
Access data from application clients
Configure data access for the Application Client
Create or changing a resource reference
Assembling data access applications
Access data using Java EE Connector Architecture connectors
Migrate applications to use data sources of the current Java EE Connector Architecture (JCA)
Configure a JDBC provider and data source


Related


Lookup names support in deployment descriptors and thin clients

+

Search Tips   |   Advanced Search