服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

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 you         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.  see also the dbcp documentation on this         and the minevictableidletimemillis configuration parameter.         -->    <parameter>      <name>maxidle</name>      <value>30</value>    </parameter>    <!-- maximum time to wait for a db connection to become available         in ms, in this example 10 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 want to use this 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 that the         mm.mysql jdbc driver will 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>
            




                    
该应用的配置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/j2eehttp://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>



    





扫描关注微信公众号