tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Access to a connection pool
Date Thu, 26 Aug 2004 12:53:28 GMT

By the servlet spec, you have to have the name of the pool twice.  Once
the server administrator defines it, and once the app deployer links to
it (this is the web.xml snippet).

If you only have one data source, you can iterate through the context
naming bindings to find the one that's a DataSource, thereby avoiding
putting its name in your code at all.  But this is not too safe.
Alternatively, you can have the build script put in the datasource name
before compiling (e.g. using an Ant filter token).

Those are some workaround, but what you're describing is standard.  If
you have a problem with it, complain to the Servlet expert group, not to
us ;)

Yoav Shapira
Millennium Research Informatics

>-----Original Message-----
>From: Philippe Mathieu []
>Sent: Thursday, August 26, 2004 3:32 AM
>To: Tomcat Users List
>Subject: Access to a connection pool
>To obtain a connection from the connection pool i use the following
>(described in the tomcat doc) :
>- First of all i describe the pool in my context.xml as a
>- then i make a link in the web.xml like that
><description> pool definition </description>
>- And i get my connection in my jsp pages :
>	Context initCtx=new InitialContext();
>	Context envCtx=(Context) initCtx.lookup("java:comp/env");
>	DataSource ds=(DataSource) envCtx.lookup("mypool");
>	Connection con=ds.getConnection();
>My pb is that the name of the pool is given three times in three
>:-(  How to avoid to give the pool name in web.xml and in my JSP pages
>How to have data sources that exist *only* in context.xml ?
>Thanks a lot
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message