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: