GeeCON Prague 2014*
The moose likes Tomcat and the fly likes provider_url for datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "provider_url for datasource" Watch "provider_url for datasource" New topic
Author

provider_url for datasource

Chee Seng
Greenhorn

Joined: May 30, 2004
Posts: 15
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);
 
GeeCON Prague 2014
 
subject: provider_url for datasource