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