Configuration and usage of Tomcat database connection pool _ MySQL

Source: Internet
Author: User
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

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.