aspose file tools*
The moose likes Websphere and the fly likes DB JNDI lookup WAS 4.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "DB JNDI lookup WAS 4.0" Watch "DB JNDI lookup WAS 4.0" New topic
Author

DB JNDI lookup WAS 4.0

Nijeesh Balan
Ranch Hand

Joined: Oct 09, 2000
Posts: 116
Hi,
We are doing a JNDI Lookup in our utility class like this.
Context ctx = new InitialContext();
DataSource ds = ctx.lookup("jdbc/dbSource");
But in the sample code i have seen, the lookup looks like this.
DataSource ds = ctx.lookup("java:comp/env/jdbc/dbSource");
Now,
1. Is there a difference in these two lookups?
2. When we do the second lookup, it throws the naming exception. This might be because for Web Modules -> Resource References name and the jndi names are different. but I am not sure.
Please let me know if you have some inputs.

Thanks & Regards,
Nijeesh.


Thanks & Regards,<br />Nijeesh.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
The top one looks it up from the global JNDI namespace. The second one looks up a name defined in the ejb-jar.xml as being local to that particular EJB (which is bound to a name in the global namespace during deployment). Read Richard Monson-Haefel's EJB book for an explanation of how JNDI works and what the two mean.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DB JNDI lookup WAS 4.0