Usage in Tomcat:
Using MYSQL as an example:
1. Copy the JDBC driver jar package (mysql-connector-java-3.1.13-bin.jar) of MySQL to the tomcat/common/lib directory.
2. Configure tomcat/CONF/server. XML, find the <globalnamingresources> label in the server. xml file, and add:
<Resource Name = "JDBC/mysqljdbc" <! -- Connection pool name -->
Type = "javax. SQL. datasource" <! -- Type -->
Driverclassname = "com. MySQL. JDBC. Driver" <! -- Driver name, full path -->
Username = "root" <! -- Database username -->
Password = "123" <! -- Database User Password -->
Maxidle = "40" <! -- Maximum idle link -->
Maxwait = "50" <! -- Maximum number of waiting connections -->
Url = "JDBC: mysql: // localhost: 3306/mysqljdbc? Useunicode = true; characterencoding = "gb2312" <! -- Link feature string -->
Maxactive = "10"/> <! -- Maximum number of active connections -->
3. Configure the tomcat/CONF/context. xml file, find the <context> tag in comtext. XML, and add the following:
<Resourcelink name = "JDBC/mysqljdbc" Global = "JDBC/mysqljdbc" type = "javax. SQL. datasource"/>
Note: The purpose of this configuration is to associate the resources configured in the server. xml file with context (last afternoon) so that the datasource object can be obtained through initcontext in the program.
4. Add:
<Resource-ref>
<Description> MySQL datasource </description>
<Res-ref-Name> JDBC/mysqljdbc </RES-ref-Name>
<Res-type> javax. SQL. datasource </RES-type>
<Res-auth> container </RES-auth>
</Resource-ref>
Use Data Connection Pool in Tomcat