In our previous articles, we have explained the first method for the problem of Tomcat and MySQL connection pools, today, we will mainly talk about the problem of Tomcat and MySQL connection pools. Another method is in $ tomcat/conf/server. <Context...> </Context> Add the following code:
Setting method:
- <Resource name = "jdbc/test" auth = "Container" type = "javax. SQL. DataSource"/>
- <ResourceParams name = "jdbc/test">
- <Parameter>
- <Name> factory </name>
- <Value> org. apache (the most popular WEB server platform on the Unix platform). commons. dbcp. BasicDataSourceFactory </value>
- </Parameter>
- <Parameter>
- <Name> username </name>
- <Value> root </value>
- </Parameter>
- <Parameter>
- <Name> password </name>
- <Value> admin </value>
- </Parameter>
- <Parameter>
- <Name> driverClassName </name>
- <Value> com. MySQL (the best combination with PHP). jdbc. Driver </value>
- </Parameter>
- <Parameter>
- <Name> url </name>
- <Value> jdbc: MySQL (the best combination with PHP): // localhost: 3306/test? AutoReconnect = true </value>
- </Parameter>
- <Parameter>
- <Name> initialSize </name>
- <Value> 20 </value>
- </Parameter>
- <Parameter>
- <Name> maxActive </name>
- <Value> 30 </value>
- </Parameter>
- <Parameter>
- <Name> maxWait </name>
- <Value> 10000 </value>
- </Parameter>
- </ResourceParams>
The general purpose of this setting is to make the data source be implemented in a separate ing directory, that is, the Code usually appears in the <Context docBase = "specific directory (such as D: \ webapps \ myjsp (preferred for SUN Enterprise Applications) "path =" Access name (e.g./myjsp (preferred for SUN Enterprise Applications )) "reloadable =" true "> </Context> to access http: // localhost: 8080/myjsp (preferred for SUN Enterprise Applications)/XXX. jsp (preferred for SUN Enterprise applications) to access a jsp in D: \ webapps \ myjsp (preferred for SUN Enterprise Applications) (preferred for SUN Enterprise applications) page to retrieve the data source or perform other operations to retrieve the data source.