• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is JNDI ?  RSS feed

 
shyam ji gautam
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please explain this concept .


i know only that we can give connectivity to database using jdbc and hybernate but what is jndi .

i know it is java naming and directory interface but what it is actully doing in terms of databse conectivity please explain it in depth


thanks
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shyam ji gautam wrote:
i know only that we can give connectivity to database using jdbc and hybernate but what is jndi .

i know it is java naming and directory interface but what it is actully doing in terms of databse conectivity please explain it in depth



JNDI is a standard to lookup resources. You have used it to find JDBC data sources, but it can also be used to find EJBs, MBeans (JMX), RMI services, or even connect to other lookup services like LDAP or Windows Active Directory. If you only used it for JDBC, then I guess it will be hard to understand why it is needed -- as it seems redundant to the driver manager.

Henry
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In terms of database connectivity it doesn't do anything
It's basically a naming service, which you could compare to DNS, if that helps?
Or even more simply you could compare its functionality to that of java.util.Map, I'm sure you're familiar with that, right?
At its core, JNDI allows you to bind an object to a unique name.
Of course that's a gross simplification, but that's the key bit of functionality.

In the context of database connectivity in a JEE environment, the actual database connectivity is provided by JDBC, as you've stated correctly.
A DataSource is commonly used to define a target for JDBC connections and as a provider of Connection objects.
JNDI comes in to play here, by mapping a DataSource to a unique name (basically), so your application can use that name to retrieve the DataSource and get a Connection.
That's all there is to it, really. JNDI is not limited to mapping names to DataSource objects, though.

you should really have a look at this tutorial, it describes what JNDI is in more detail, and how it can abstract access to a variety of naming services.

Edit: Ugh, Henry beat me.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!