MySql configuration uses DBCP connection pool

        Find server.xml in the server directory and add the following code to the Host tag

<Context path="/project name" docBase="Webpage path (absolute path)" reloadable="true">
         <Resource
              name="jdbc/pool"
              type="javax.sql.DataSource"
              username="root"
              password="root"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/database name"
              maxActive="300"
              maxIdle="100"
              maxWait="5000"
              removeAbandoned="true"
              removeAbandonedTimeout="600"   
              logAbandoned="true"
          auth="Container"
                />
        </Context>

         Add the following code to the web.xml file of the project

<resource-ref>
        <description>mysql database connection pool</description>
        <!-- Refer to the data source name, which is consistent with the name attribute value "jdbc/mysqlds" in the Resource node configured in Tomcat -->
        <res-ref-name>jdbc/pool</res-ref-name>
        <!-- resource type -->
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

         Add the mysql-jdbc driver jar package to the lib folder in the server directory, the version must be above 5.1, see attachment

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326484378&siteId=291194637