Connection factory JNDI name tips

Distributed computing environments often employ naming and directory services to obtain shared components and resources. Naming and directory services associate names with locations, services, information, and resources.

Naming services provide name-to-object mappings. Directory services provide information on objects and the search tools required to locate those objects. There are many naming and directory service implementations, and the interfaces to them vary.

Java Naming and Directory Interface (JNDI) provides a common interface that is used to access the various naming and directory services. After you have set this value, saved it, and restarted the server, be able to see this string when you run dumpnamespace.

For WebSphere Application Server specifically, when you create a data source the default JNDI name is set to jdbc/data_source_name. When you create a connection factory, its default name is eis/j2c_connection_factory_name. You can, of course, override these values by specifying your own.

In addition, if you click the checkbox Use this data source for container managed persistence (CMP) when you create the data source, another reference is created with the name of eis/jndi_name_of_datasource_CMP. For example, if a data source has a JNDI name of jdbc/myDatasource, the CMP JNDI name is eis/jdbc/myDatasource_CMP. This name is used internally by CMP and is provided simply for informational purposes.

When creating a connection factory or data source, a JNDI name is given by which the connection factory or data source can be looked up by a component. Generally an "indirect" name with the java:comp/env prefix should be used. This makes any resource-reference data associated with the application available to the connection management runtime, to better manage resources based on the res-auth, res-isolation-level, res-sharing-scope, and res-resolution-control settings.

While the use of a direct JNDI name is supported, such use results in default values of these resource-ref data. You will see an informational message logged such as this:

J2CA0122I: Resource reference abc/myCF could not be located, so default values of the following are used: [Resource-ref settings]
             res-auth:                 1 (APPLICATION)
             res-isolation-level:      0 (TRANSACTION_NONE)
             res-sharing-scope:        true (SHAREABLE)
             res-resolution-control:   999 (undefined)


Related concepts
Connection factory
Data sources