Tomcat6 MySQL connection pool Configuration

Source: Internet
Author: User

The Java + JSP + tomcat6 + MySQL connection pool I recently saw on the Internet is mostly tomcat5. Many of them are not detailed and cannot be configured, which makes us very time-consuming and brainless, today, I finally successfully configured the connection pool of the latest atat6 + MySQL, And I will share the following:

 

1. required files:

Installation File)

 

2. ConfigureContext. xml file

 

Add a connection pool between <context> </context> as follows:

  1. <Resource Name = "JDBC/MySQL"
  2. Auth = "Container"
  3. Type = "javax. SQL. datasource"
  4. Driverclassname = "com. MySQL. JDBC. Driver"
  5. Url = "JDBC: mysql: // localhost/test"
  6. Username = "root"
  7. Password = "root"
  8. Maxactive = "100"
  9. Maxidle = "30"
  10. Maxwait = "10000" type = "codeph" text = "/codeph"/>

I don't need to talk about the above parameters. I know what it means.

 

3. Configure web. xml under your application

 

<Web-app> </Web-app>:

XML Code
  1. <Resource-ref>
  2. <Description> dB connection </description>
  3. <Res-ref-Name> JDBC/mysqlx </RES-ref-Name>
  4. <Res-type> javax. SQL. datasource </RES-type>
  5. <Res-auth> container </RES-auth>
  6. </Resource-ref>

4. Success

 

Do not use the original server. after the configuration is in XML, you can write the test program below. There will be a lot on the internet, mainly on the top. Of course, you need to put the connection drivers under the Lib under Tomcat 6.

 

Gengv: verified and successful.

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.