Configure the MySQL database connection pool in Tomcat

Source: Internet
Author: User

1. Add the configuration information in $ CATALINA_HOME/conf/server. xml (standardization is getting closer and closer) and declare the specific information of the connection pool. Add the following content:
  
<! -- Declare the connection pool -->
  
<Resource name = "jdbc/MySQL (the best combination with PHP)" auth = "Container" type = "javax. SQL. DataSource"/>
  
<! -- Set the connection pool parameters -->
  
<ResourceParams name = "jdbc/MySQL (the best combination with PHP)">
  
<Parameter>
  
<Name> factory </name>
  
<Value> org. apache (the most popular WEB server platform on the Unix platform). commons. dbcp. BasicDataSourceFactory </value>
  
</Parameter>
  
<Parameter>
  
<Name> maxWait </name>
  
<Value> 5000 </value>
  
</Parameter>
  
<Parameter>
  
<Name> maxActive </name>
  
<Value> 20 </value>
  
</Parameter>
  
<Parameter>
  
<Name> username </name>
  
<Value> shopadm </value>
  
</Parameter>
  
<Parameter>
  
<Name> password </name>
  
<Value> 123 </value>
  
</Parameter>
  
<Parameter>
  
<Name> url </name>
  
<Value> jdbc: MySQL (the best combination with PHP): // localhost/shopdb? UseUnicode = true & charact-erEncoding = gb2312 </value>
  
</Parameter>
  
<Parameter>
  
<Name> driverClassName </name>
  
<Value> com. MySQL (the best combination with PHP). jdbc. Driver </value>
  
</Parameter>
  
<Parameter>
  
<Name> maxIdle </name>
  
<Value> 10 </value>
  
</Parameter>
  
</ResourceParams>
  
2. Add the following information before $ CATALINA_HOME/conf/web. xml (standardization is getting closer and closer) </web-app>:
  
<Resource-ref>
  
<Description> DB Connection </description>
  
<Res-ref-name> jdbc/MySQL (the best combination with PHP) </res-ref-name>
  
<Res-type> javax. SQL. DataSource </res-type>
  
<Res-auth> Container </res-auth>
  
</Resource-ref>
  
The parameter names in <res-ref-name> must be the same as the connection names declared in server. xml (standardization is getting closer and closer.
  
3. in the $ CATALINA_HOME/conf/catalina/localhost directory, find the configuration information of the current program for database connection, for example, shopping. xml (standardization is getting closer and closer), add the following information to this file:

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.