• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

provider_url for datasource

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic