The moose likes JDBC and the fly likes difference between a jndi lookup and java:comp look up? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "difference between a jndi lookup and java:comp look up?" Watch "difference between a jndi lookup and java:comp look up?" New topic
Author

difference between a jndi lookup and java:comp look up?

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi Please tell me

what is the difference between a jndi lookup and java:comp look up?

When googled found this "Use a Direct Lookup when everything is in same JVM ,use java:comp when you are looking at a Resource on a different server."

But i have seen a lot of codings within the same JVM but still use java:comp look up .

so i am getting confused here .


Save India From Corruption - Anna Hazare.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Ravi,

One thing is java:comp lookup is portable ,where as global JNDI lookup through context are not.

Say if you lookup datasource through JNDI in global context, when you change your underlying database , JNDI differs so does your code . where as if you use java:comp , change in web.xml / vendor specific xml alone.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Balu , I did not understand .

If we use Global JNDI (without using java:comp) why does it require a change in the code ??

Please explain .
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


this is just example.
Say If you change your database, your JNDI lookup changes , the code changes. where as the other way (java:comp) your xml alone changes
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: difference between a jndi lookup and java:comp look up?
 
Similar Threads
Logical names Vs JNDI names
Packaging an EAR
Dependancy Injection when 2 Beans implement the same interface
Tomcat 7: Can I configure it so that I don't need to use “java:/comp/env” in the code?
JNDI question in JBoss environment