Hi,
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 [mailto:[EMAIL PROTECTED]
>Sent: Thursday, August 26, 2004 3:32 AM
>To: Tomcat Users List
>Subject: Access to a connection pool
>
>Hi,
>
>To obtain a connection from the connection pool i use the following
code
>(described in the tomcat doc) :
>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-example
s-
>howto.html
>
>- First of all i describe the pool in my context.xml as a
*localDataSource*
>
>- then i make a link in the web.xml like that
>
><resource-ref>
><description> pool definition </description>
><res-ref-name>mypool</res-ref-name>
><res-type>javax.sql.DataSource</res-type>
><res-auth>Container</res-auth>
></resource-ref>
>
>
>- 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
different
>files
>:-(  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
>--
>PM
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to