A server.xml of Tomcat and MySQL

Source: Internet
Author: User
Tags auth resource xmlns tomcat
Mysql|server|xml $CATALINA _home/conf/server.xml


<context path= "/dbtest" docbase= "dbtest"
debug= "5" reloadable= "true" crosscontext= "true" >

<logger classname= "Org.apache.catalina.logger.FileLogger"
Prefix= "Localhost_dbtest_log." suffix= ". txt"
Timestamp= "true"/>

<resource name= "Jdbc/testdb"
Auth= "Container"
Type= "Javax.sql.DataSource"/>

<resourceparams name= "Jdbc/testdb" >
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!--Maximum number of DB connections in pool. Make sure
Configure your mysqld max_connections large enough to handle
All of your DB connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<!--Maximum number of idle DB connections to retain in pool.
Set to-1 for No limit. Also the DBCP documentation on this
And the Minevictableidletimemillis configuration parameter.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<!--Maximum A DB connection to become available
In MS, example seconds. An Exception is thrown if
This timeout is exceeded. Set to-1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<!--MySQL db username and password for DB connections-->
<parameter>
<name>username</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>

<!--Class name for the "old" Mm.mysql JDBC driver-uncomment this entry and comment next
If you are want to use the Driver-we recommend using connector/j though
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
-->

<!--Class name for the official MySQL connector/j driver-->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>

<!--the JDBC connection URL for connecting to your MySQL DB.
The autoreconnect=true argument to the URL makes sure
Mm.mysql JDBC Driver'll automatically reconnect if mysqld closed the
Connection. Mysqld By default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context> configuration of the application Web-inf/web.xml <web-app xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee
Http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "
version= "2.4" >
<web-app>
<description>mysql Test app</description>
<resource-ref>
<description>db connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>



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.