You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mighty Tornado <mi...@gmail.com> on 2009/03/23 00:38:50 UTC

Tomcat Data sources and connection pools

Hi,
A couple of questions regarding Tomcat 6 Data Sources.

1. I used WebLogic previously and there you had to configure connection
pools and then create data sources and link them to connection pools.

Is the process the same in Tomcat?

2. From what I understand I need to create the data source definition in the
Context element of an xml file. Which xml file is it?

Thanks.

RE: Tomcat Data sources and connection pools

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mighty Tornado [mailto:mighty.tornado@gmail.com] 
> Subject: Re: Tomcat Data sources and connection pools
> 
> Tomcat will read the context.xml file in the META-INF 
> directory and get the data source from there?

Yes.

> I also added a resource ref in my web.xml because that's what various
> tutorials suggest. After that is done, how do I obtain a connection?

Again, read the doc; examples are in there:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

> is it correct to make a DAO a singleton?

The answer to that depends on what DAO mechanism you're using, and how you intend to use it.  It's not really a Tomcat topic.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Data sources and connection pools

Posted by Mighty Tornado <mi...@gmail.com>.
So do I understand this correctly?
Tomcat will read the context.xml file in the META-INF directory and get the
data source from there?

I also added a resource ref in my web.xml because that's what various
tutorials suggest. After that is done, how do I obtain a connection?

and one more question, is it correct to make a DAO a singleton?

Thanks,


On Sun, Mar 22, 2009 at 7:57 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Mighty Tornado [mailto:mighty.tornado@gmail.com]
> > Subject: Tomcat Data sources and connection pools
> >
> > 1. I used WebLogic previously and there you had to configure
> > connection pools and then create data sources and link them
> > to connection pools.
>
> You can manage the pool yourself, but it's certainly easier if you let
> Tomcat do it.  The doc is here:
> http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
>
> > 2. From what I understand I need to create the data source
> > definition in the Context element of an xml file. Which xml
> > file is it?
>
> You can define the data source in a <Context> file if you want it available
> only to one webapp, or as a <GlobalResource> if you want it available to all
> webapps.  A <Context> element describes the Tomcat-specific configuration
> for a webapp; it is normally located within the webapp at
> META-INF/context.xml, or you can also put it at
> conf/Catalina/[host]/[appName].xml if you want to keep it outside of the
> webapp's .war file or directory.  (For compatibility with older Tomcat
> versions, you can also put it in conf/server.xml, but that's strongly
> discouraged these days.)  Doc is here:
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
>
> Do not use the path of docBase attributes when using one of the standard
> location for your <Context> element and webapp.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Tomcat Data sources and connection pools

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mighty Tornado [mailto:mighty.tornado@gmail.com] 
> Subject: Tomcat Data sources and connection pools
> 
> 1. I used WebLogic previously and there you had to configure 
> connection pools and then create data sources and link them 
> to connection pools.

You can manage the pool yourself, but it's certainly easier if you let Tomcat do it.  The doc is here:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

> 2. From what I understand I need to create the data source 
> definition in the Context element of an xml file. Which xml
> file is it?

You can define the data source in a <Context> file if you want it available only to one webapp, or as a <GlobalResource> if you want it available to all webapps.  A <Context> element describes the Tomcat-specific configuration for a webapp; it is normally located within the webapp at META-INF/context.xml, or you can also put it at conf/Catalina/[host]/[appName].xml if you want to keep it outside of the webapp's .war file or directory.  (For compatibility with older Tomcat versions, you can also put it in conf/server.xml, but that's strongly discouraged these days.)  Doc is here:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

Do not use the path of docBase attributes when using one of the standard location for your <Context> element and webapp.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org