Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

database connection from JNDI

 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
i always run into the following line of code as far as database connection is concerned from servletcontext:

i never seem to find out where the java:comp/env is defined. can you please explain me whatjava:comp/env is and where it is set up so that we could use it? thanks.
[ April 08, 2003: Message edited by: Himal Chuli ]
 
Lilac Ezer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java:comp/env is simply the root context for JNDI mappings you declare in your application. If you define a JDBC connection mapped to JNDI name jdbc/myDB, then you can access it through the context java:comp/env/jdbc/myDB. You never need to worry about defining java:comp/env anywhere. Some application servers (like JRun) will not require you to enter java:comp/env when performing a lookup, so check the documentation of your specific J2EE server for more information on JNDI names.
 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply to my concerns which helped me understand relatively better than before. But where and how is the java:comp/env defined so that JNDI recognize it? could i find the place it is defined and change it to something i would like to?
thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic