P164 example 5-1 Common SQL statements
P178 Database connection Pool (1) The role of connection pooling
Store multiple database connection objects, get 1 connections from the pool when the program needs it, and then return the connection pool when the program executes. Avoid the overhead of database connection establishment and shutdown. Increase database access speed.
(2) Steps to use connection pooling in Tomcat
1. Config\context.xml in the Tomcat directory, add the following to the tag <context>:
<Resourcename= "Jdbc/xxx"Auth= "Container"type= "Javax.sql.DataSource"Maxidle= "Ten"maxwait= "+"maxactive= "Ten"username= "root"Password= "root"Driverclassname= "com. MySql.jdbc.Driver "URL= "Jdbc:mysql://localhost:3306/xxx"/>
2. Locate the Web. XML configuration file in the project Web-inf directory, then open it and add the following to the label <web-app>:
<Resource-ref> <Description>DB Connection</Description> <Res-ref-name>Jdbc/xxx</Res-ref-name> <Res-type>Javax.sql.DataSource</Res-type> <Res-auth>Container</Res-auth></Resource-ref>
3. Place the JDBC driver jar package in the Lib folder in the Tomcat installation directory.
(3) Example 5-4
JSP Web Fifth Chapter review JSP Access database