Configuring Tomcat connection pooling (configuring Server.xml files)

Source: Internet
Author: User
Tags auth connection pooling

To configure the Tomcat connection pool:

1, configure Conf/server.xml, create DataSource resources, and specify parameters for them;

2. Referencing resources in the web.xml;

3, the use of resources in JavaBean, servlet;

Server.xml File Contents

<!--path= "/tomcatdbpools" indicates what characters you want to use to access the site, the way the site is accessed by/tomcatdbpools end

Example: Http://localhost:8080/TomcatDbPools

Docbase= "Tomcatdbpools" where your components are placed without/then find from the WebApps directory

debug= "0" reloadable= "true" is fixed-->

<context path= "/tomcatdbpools" docbase= "Tomcatdbpools" debug= "0" reloadable= "true" >

<!--name Specifies the name of the resource Jndi of the resource pool to the connection pool Jdbc/tomcatdbpool1

Auth: Administrative permissions specify the manager for the management resource, which can be container or application

Type: Indicates the class name to which the resource belongs, what type of data source This example is SQL-->

<resource name= "Jdbc/tomcatdbpool1" auth= "Container" type= "Javax.sql.DataSource"/>

<resourceparams name= "Jdbc/tomcatdbpool1" >

The connection pool configuration parameter named for, that is Jdbc/tomcatdbpool

<!--Specifies the name of Dataresource factory-->

<parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

<!--Specify the maximum number of active connections in the connection pool 0 indicates unrestricted-->

<parameter>

<name>maxActive</name>

<value>100</value>

</parameter>

<!--Specify the maximum number of idle connections 0 means unrestricted-->

<parameter>

<name>maxIdle</name>

<value>30</value>

</parameter>

<!--the maximum number of milliseconds to wait in the connection pool, 1 indicates infinite wait-->

<parameter>

<name>maxWait</name>

<value>10000</value>

</parameter>

User name and password for the <!--connection-->

<parameter>

<name>username</name>

<value></value>

</parameter>

<parameter>

<name>password</name>

<value></value>

</parameter>

<!--driver JDBC Bridge-->

<parameter>

<name>driverClassName</name>

<value>sun.jdbc.odbc.JdbcOdbcDriver</value>

</parameter>

URL of the <!--database-->

<parameter>

<name>url</name>

<value>jdbc:odbc:bookDSN</value>

</parameter>

</ResourceParams>

<!--we can also point to multiple resources so that it's OK to indicate which one is referenced in the web.xml.

The following is the use of SqlServer2000 driver to access the database

The premise is to copy SQL Server's drivers to the Common/lib directory under Tomcat-->

<resource name= "Jdbc/tomcatdbpool2" auth= "Container" type= "Javax.sql.DataSource"/>

<resourceparams name= "Jdbc/tomcatdbpool2" >

<!--Specifies the name of Dataresource factory-->

<parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

<!--Specify the maximum number of active connections in the connection pool 0 indicates unrestricted-->

<parameter>

<name>maxActive</name>

&n

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.