What is the Difference Between JNDI and JDBC

Question: What is the Difference Between JNDI and JDBC?

Answer: JDBC is java database API, while JNDI is java native directory API.

The main thing in here is that in a JNDI directory you’re actually storing a JDBC DataSource, so, you’re simply using JDBC and obtain a Connection via JNDI lookup.

In short words: JDBC is a Database realm, JNDI lets you store Objects in a virtual context (the Directory) that can be local, remote (Implementation details usually don’t matters).

You access this context via names, obtaining stored objects, it is good to share things among different modules.

Application Servers usually have a JNDI Context for sharing global objects amon different application, Connection Poolers happen to be one of the most clear examples of why sharing via JNDI is good. 

JNDI is the directory that contains the list of objects defined on the server. When the user requests for a connection pool, the code would look for the object on the JNDI and would get the requested connection pool from the data source. JDBC is the one which does all the interactions with the database. An application will lookup the JNDI to get a connection pool for it to interact with the database.

Note: Browse latest  Weblogic interview questions and  Weblogic tutorial. Here you can check  Weblogic Training details and  Weblogic training videos for self learning. Contact +91 988 502 2027 for more information.

Leave a Comment

Scroll to Top