JNDI Coding Examples

The most common use of JNDI in Java applications is to access resources in a naming service. Since JNDI allows access to a variety of naming services, the resource access can be one of a number of different types of resources. The resource could simply be a string or other primitive data type containing some important program property, such as a closing date for an accounting transaction, the name of a server that contains a resource, or a standard discount rate for a transaction. Or more commonly, the resource could be an object that encapsulates access to a service such as a database or a message queue.

The JDBC DataSource object is the method of choice for accessing a database. The DataSource contains the information needed ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.