Set JNDI resources for Tomcat

Source: Internet
Author: User
Tags xml file example

The Web application descriptor file (/WEB-INF/web. xml) can be used to set the creation and reference of resources.
There are three elements used for setting:
L <env-entry>
L <resource-ref>
L <resource-env-ref>
If Tomcat cannot identify the appropriate resource factory, or you need to set other information. You must set the necessary information before creating resources in Tomcat. This information is generally found in $ CATALINA_BASE/conf/server. set in the xml file, preferably in the context setting file for each Web application (META-INF/context. xml. The following elements are used for setting:
L <Environment>
L <Resource>
L <ResourceLink>
L <Transaction>
Resources defined in context. xml do not need to be defined in web. xml. We recommend that you retain the definition in web. xml to demonstrate the resource requirements of web applications.
If resources with the same name are defined in context. xml and web. xml, the override attribute is set to true only in context. xml.
Global settings
The element <GlobalNamingResources> in $ CATALINA_BASE/conf/server. xml is used to set global resources of the server. <ResourceLink> can be used in context. xml of a Web application to include these resources. There is no need to define such resources in web. xml. We recommend that you keep the definition in web. xml to describe the resource requirements of web applications.
Web. xml file example:
<Resource-ref>
<Description>
Resource reference to a factory for java. SQL. Connection
Instances that may be used for talking to a participant
Database that is configured in the <Context>
Login artion for the web application.
</Description>
<Res-ref-name>
Jdbc/EmployeeDB
</Res-ref-name>
<Res-type>
Javax. SQL. DataSource
</Res-type>
<Res-auth>
Container
</Res-auth>
</Resource-ref>
 
 
Context. xml file example:
<Context...>
...
<Resource name = "jdbc/EmployeeDB"
Auth = "Container"
Type = "javax. SQL. DataSource"
Username = "dbusername"
Password = "dbpassword"
DriverClassName = "org. hsql. jdbcDriver"
Url = "jdbc: HypersonicSQL: database"
MaxActive = "8"
MaxIdle = "4"/>
...
</Context>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.