mysql| Data | database | database connection
After a long day of practice and groping, and finally under Tomcat successfully configured MySQL database connection pool. Summarized as follows:
1. Add the configuration information to the $catalina_home/conf/server.xml, declare the connection pool specific information, add the following content:
2. Add the following information before the </web-app> of $catalina_home/conf/web.xml:
<resource-ref>
<description>db connection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
The parameter names in <res-ref-name> must be the same as the connection names declared in Server.xml.
3. Locate the configuration information for the current program that requires a database connection in the $catalina_home/conf/catalina/localhost directory, such as Shopping.xml, and add the following information to this file:
On this basis, refer to the Tomcat official website user manual, explore another way to configure the connection pool, this method does not need to modify the Server.xml, as long as the need to use the connection pool of the program's configuration document to modify it. The method is as follows:
1. $CATALINA _home/conf/catalina/localhost directory to find the configuration document for the program that requires the database connection pool, this is shopping.xml. Add the following information between <Context></Context> to declare a database connection pool:
The key is the Italic section, pointing to the connection pool that was declared earlier.
Both of these methods can be configured successfully, and obviously their scope is not the same. In addition, the configuration of the internal reference and operating mechanism, left to further study. The next step is to learn how to work together with database connection pooling and JSP.
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.