- The Java Naming and Directory Interface (JNDI) is a standard Java API for naming and directory services.
- It allows Java-based technologies to discover and organize named components in a distributed computing environment.
- Each datasource requires a unique JNDI name, assigned using the jndi-name attribute.
- Components that need to obtain a database connection from a pool use the jndi-name value to lookup the pool in the JNDI naming service.
- A valid JNDI name for a datasource must start with "java:" or "java:/jboss".
Hope, this helps you...
JNDI stands for Java Naming & Directory interfaces. Roughly, this can be compared to telephone directory.
JNDI is a service mostly provided by servers(both web & application). This enables you to refer to resources in the server by a generic name.
Instead of hard-coding database details in the application, a datasource can be created in the server which provides functionality of connection-pooling and give a name to this datasource to refer in the code. When you ask for a connection for the server, you can directly refer to the name you had given to the datasource instead of hardcoding the database connection details.
This enables you to make your code independent of environment specific settings.