Obtaining an Initial Context

The first step in using the JNDI name service is to get a context in which to add or find names. The context that represents the entire namespace is called the Initial Context and is represented by a class called javax.naming.InitialContext and is a sub-class of the javax.naming.Context class.

A Context object represents a context that you can use to look up objects or add new objects to the namespace. You can also interrogate the context to get a list of objects bound to that context.

The javax.naming package contains all the simple JNDI classes. Sub-packages within the javax.naming package provide additional JNDI functionality, such as directory-based features like attributes.

The following code creates an initial context using the default JNDI service information:

Context ctx = new InitialContext();

If something goes wrong when creating the initial context, a NamingException is thrown.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.216