JSP Web Fifth chapter review JSP Access database

Source: Internet
Author: User
Tags auth connection pooling access database

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.