• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is JNDI  RSS feed

 
Mikael Molin
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can someone explain what JNDI is. How is it defined? (any special standards), can i make my own ?.
EX. java:comp/env/jdbc
can i write like this java:cmonth/street/jdbc,
is it up to me to write what i want in the url or does it have to be like a certain pattern in it.
What is my own JNDI ?
Is it already there or what.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNDI stands for Java Naming and Directory Interface. It's an API for working with directory services such as LDAP.

It's used in Java EE servers for different things. For example, in the configuration of your server you define a JDBC data source. The server will create a DataSource object and register it, and in your application components (for example, servlets or EJBs) you can lookup the DataSource object using the JNDI API.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mikael Molin wrote:Hi,


is it up to me to write what i want in the url or does it have to be like a certain pattern in it.
What is my own JNDI ?
Is it already there or what.


Definitely you should go through the links pointed by Jepser to understand what JNDI is all about and how it is dealt with.

However, to answer your other questions in a precise way, the URLs are actually standardized based on the vendors who implement the JNDI and hence you are expected to follow the pattern recommended. However, at the end of the JNDI URL, you are free to choose the unique Id for the object/component you are registering.

For example, java:comp/env may be a standard one and you can NOT change this. However, at the end of /env, you can add your own id like "java:comp/env/myJDBCDataSource" or "java:comp/env/oracleDS" etc.,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!