Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

provider_url for datasource

 
Chee Seng
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can a java application get the datasource object from tomcat server?

I tried but got "javax.naming.NameNotFoundException: Name java:comp is not bound in this Context".

It works if I run it from a servlet. What is the corrent PROVIDER_URL value?

the code :
----------
env.putContext.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
env.put(Context.PROVIDER_URL, "localhost:8080");
env.put(Context.URL_PKG_PREFIXES, "org.apache.naming");
initContext = new InitialContext(env);
ds = (DataSource)initContext.lookup("java:comp/env/jdbc/myDB);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic