File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: provider_url for datasource
 
Similar Threads
j2ee newbie question about context and lookup
NameNotFoundException with SUN's Application Server 8.1
Sun one application server and connection pool
connection pooling in websphere 5.1
tomcat -> orion javax/ security/ auth/ login/ LoginException