tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Garrett <>
Subject Re: ContextEjb & related deploy classes
Date Tue, 14 Aug 2001 19:36:34 GMT
Thanks for the help! I was still confused as to how the web app gets 
the information, but what you gave me pointed me to the 
StandardContext.createNamingContext() method and it all makes perfect 
sense, now.

Incidentally, as I continue to try to understand the codebase, I'll 
probably have similar questions. I'll try to puzzle out the answers 
by reading the code, specs, and list archives, but lacking that, is 
this the appropriate place to ask questions about the source, or 
should that be confined to tomcat-user?

Thanks again,

>Let's say that what you want to do is access a connection pool (i.e. an
>implementation of javax.sql.DataSource) as you are building a web app on
>Tomcat 4, and you want to use exactly the same code that you will use when
>the app is deployed on a J2EE server -- something like this:
>   Context initialContext = new InitialContext();
>   DataSource ds = (DataSource)
>    initialContext.lookup("java:comp/env/jdbc/EmployeeAppDB");
>   Connection conn = ds.getConnection();
>   ... use this Connection ...
>   conn.close();  // Return connection to the pool
>Now, in your application's web.xml, you declare a reference to this
>connection pool, but without details:
>   <resource-env-ref>
>     <resource-env-ref-name>jdbc/EmployeeAppDb</resource-env-ref-name>
>     <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
>   </resource-env-ref>
>The actual linkage of this connection pool to a "real" database happens
>inside Tomcat 4's "server.xml" file -- see the declaration of the
>"/examples" context.

View raw message