Configure MySQL's connection pool under Tomcat

Source: Internet
Author: User
Tags requires tomcat

1. Add the configuration information in the $catalina_home/conf/server.xml, declare the specific information of the connection pool, add the following

Factory

Org.apache.commons.dbcp.BasicDataSourceFactory

Maxwait

5000
Maxactive

20
Username

Shopadm

Password

123
Url

jdbc:mysql://localhost/shopdb?useunicode=true&charact-erencoding=gb2312

Driverclassname

Com.mysql.jdbc.Driver
Maxidle

10
2. Add the following information before $catalina_home/conf/web.xml:

DB Connection

Jdbc/mysql

Javax.sql.DataSource

Container
The parameter names in these 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:
...
...
Done!
  
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 to declare a database connection pool:

Factory

Org.apache.commons.dbcp.BasicDataSourceFactory
Maxwait

5000
Maxactive

20
Password

123
Url

Related Article

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.