• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is JNDI ?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic