Use Data Connection Pool in Tomcat

Source: Internet
Author: User
Usage in Tomcat:
Using MYSQL as an example:
1. Copy the JDBC driver jar package (mysql-connector-java-3.1.13-bin.jar) of MySQL to the tomcat/common/lib directory.
2. Configure tomcat/CONF/server. XML, find the <globalnamingresources> label in the server. xml file, and add:
<Resource Name = "JDBC/mysqljdbc" <! -- Connection pool name -->
Type = "javax. SQL. datasource" <! -- Type -->
Driverclassname = "com. MySQL. JDBC. Driver" <! -- Driver name, full path -->
Username = "root" <! -- Database username -->
Password = "123" <! -- Database User Password -->
Maxidle = "40" <! -- Maximum idle link -->
Maxwait = "50" <! -- Maximum number of waiting connections -->
Url = "JDBC: mysql: // localhost: 3306/mysqljdbc? Useunicode = true; characterencoding = "gb2312" <! -- Link feature string -->
Maxactive = "10"/> <! -- Maximum number of active connections -->
3. Configure the tomcat/CONF/context. xml file, find the <context> tag in comtext. XML, and add the following:
<Resourcelink name = "JDBC/mysqljdbc" Global = "JDBC/mysqljdbc" type = "javax. SQL. datasource"/>
Note: The purpose of this configuration is to associate the resources configured in the server. xml file with context (last afternoon) so that the datasource object can be obtained through initcontext in the program.
4. Add:
<Resource-ref>
<Description> MySQL datasource </description>
<Res-ref-Name> JDBC/mysqljdbc </RES-ref-Name>
<Res-type> javax. SQL. datasource </RES-type>
<Res-auth> container </RES-auth>
</Resource-ref>

Use Data Connection Pool in Tomcat

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.