tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Date Thu, 01 Feb 2007 14:30:52 GMT
Fran Varin wrote:
> Hi, 
> We are in the process of trying to use Tomcat 5.5.20 to access an existing
> DB2 Database. Up until this point the application has been running under
> WebSphere (We are trying to utilize Tomcat for testing purposes). In
> WebSphere we can supply an IBM JNDI Factory Class named
> "" as the
> "Context.INITIAL_CONTEXT_FACTORY". We can then find our driver and all is
> well. 
> Clearly, in Tomcat the above mentioned class does not exist. I've been all
> over the place trying to find an equivalent class that is part of Tomcat. It
> boils down to my attempt at using
> "". However, when I do I receive
> "javax.naming.NameNotFoundException: Name jdbc is not bound in this
> Context:". 
> I need to resolve this issue in order to move forward with using Tomcat but,
> cannot seem to find a good example that explains how to do this. I've seen
> the documents that loosely describe change server.xml and creating a
> context.xml for the application. But, this seems like the wrong path given
> the way that we have always proceeded with creating DB connections. So, it
> has really just added to my confusion. 
> Any help would be greatly appreciated, 
> Fran 

InitialContext initialContext = new InitialContext();
Context rootContext = (Context) initialContext.lookup("java:comp/env");
DataSource ds = (DataSource) rootContext.lookup("jdbc/Database");

Assuming that you've configured a DataSource in server.xml.


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message