了解tomcat的context.xml配置文件

时间:2016-02-10 20:31:20

标签: spring hibernate tomcat7 c3p0 sessionfactory

我在context.xml文件夹中有tomcat/conf个文件:

<Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>      
    <Resource 
        auth="Container" 
        description="DAPS Database" 
        driverClass="net.sourceforge.jtds.jdbc.Driver"      
        testConnectionOnCheckin="true" 
        idleConnectionTestPeriod="300" 
        maxIdleTime="240"
        minPoolSize="3" 
        maxPoolSize="20" 
        acquireIncrement="1" 
        name="jdbc/stem" 
        user="dbuser" 
        password="p@ssword" 
        factory="org.apache.naming.factory.BeanFactory" 
        type="com.mchange.v2.c3p0.ComboPooledDataSource" 
        jdbcUrl="jdbc:jtds:sqlserver://000.000.0.00/stem;user=dbuser;password=p@ssword;TDS=8.0" 
    />  
  <Manager pathname="" />
</Context>

我的应用程序的WEB-INF application-context.xml文件:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
            <value>java:comp/env/jdbc/stem</value>
        </property>
    </bean>
    <!-- Hibernate properties to be used in the Session Factory -->
    <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="properties">
        <props>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.c3p0.minPoolSize">20</prop>
            <prop key="hibernate.c3p0.maxPoolSize">1000</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.c3p0.min_size">4</prop>
            <prop key="hibernate.c3p0.max_size">10</prop>
            <prop key="hibernate.c3p0.timeout">600</prop>
            <prop key="hibernate.c3p0.max_statements">1000</prop>
            <prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
            <prop key="hibernate.cache.use_second_level_cache">false</prop>
        </props>
        </property>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <ref bean="hibernateProperties" />
        </property>
        <property name="mappingResources">
            <list>      
              <value>mil/dla/daps/model/businessobject/login/Address.hbm.xml</value>                    
               <value>mil/dla/daps/model/businessobject/login/State.hbm.xml</value>
                </list>
            </property>
        </bean>
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory">
                <ref local="sessionFactory" />
            </property>
        </bean>

有人可以解释为什么会有人使用这些值:

  • type =“com.mchange.v2.c3p0.ComboPooledDataSource”
  • driverClass =“net.sourceforge.jtds.jdbc.Driver”
  • 工厂= “org.apache.naming.factory.BeanFactory”

如果这应该与我的应用程序的application-context.xml文件匹配

我正在研究这个并试图了解正在发生的事情的原因是因为如果Tomcat被30多个用户击中并且正在耗尽所有资源,那么Tomcat会不停地挂起。

查看数据库服务器,我看到数百个来自Tomcat服务器的TCP连接。

0 个答案:

没有答案