Configuration and use of Tomcat database connection pool
BitsCN.com
It is estimated that the Tomcat database connection pool is not used much now. Currently, it is DBCP, C3P0, and so on. in many software projects, dbcp and c3p0 are really good. you can use them as needed, it may not be very convenient to use the Tomcat connection pool. However, it was found that using the Tomcat database connection pool in distributed servers or database Shards is really good. you can open the connection pool on different databases at one time;
The following is the configuration file. the server. xml file under conf (all original content is cleared)
ps="false" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true"/>
There are a total of four databases. of course, these databases are not only on one machine, but can be specified through URLs under the Resource node. These libraries are all local databases, add the mysql connection package to the lib directory under Tomcat;
The Context node configures the Tomcat container to be used only for the project of myproject. you can directly start Tomcat without deploying it. this can speed up the startup. when Tomcat is started, the database
The connection is also opened. you only need to read the connection from the jav project.
The connection format is as follows:
DataSource datesource1="java:comp/env/jdbc/table"
DataSource datesource2="java:comp/env/jdbc/tablelog"
DataSource datesource3="java:comp/env/jdbc/tableR1"
DataSource datesource4="java:comp/env/jdbc/tableR2"
In this way, you can obtain connections to multiple databases in a project; it is indeed very powerful;
The meaning of each node in Tomcat server. xml is no longer mentioned here. you can understand it literally.
BitsCN.com