Detailed explanation of tomcat connection pool configuration

<bean class="org.apache.tomcat.jdbc.pool.PoolProperties">  
    <property name="url" value="${jdbcUrl}"/> 
        <!--数据库驱动--> 
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/> 
        <!--用户名-->
        <property name="username" value="mysql"/>  
        <!--密码-->
        <property name="password" value="123456"/>
        <!--Register pool JMX, default: true -->   
        < property name ="jmxEnabled" value ="false" />   
        <!-- Interval for checking connection dead and alive, unit: milliseconds -->         
        < property name ="validationInterval" value = "30000" /> 
        <!-- Specifies whether the connection has been verified by the idle object eviction process when it enters the idle state. If the verification fails, the connection will be disconnected by the connection pool
         If the value is true, the validationQuery parameter must be a non-empty string -- --> 
        < property name = "testWhileIdle" value = = "false" />    
        <!-- Specifies whether the connection is verified when it is returned to the pool
         If the value is true, the validationQuery parameter must be a non-empty string -- --> 
        < property name = "testOnReturn" value = = "false" />   
        <!-- Specify whether the connection is verified when it is called, if the verification If it fails, the connection is disconnected by the connection pool, and the connection pool attempts to call another connection
         If the value is true, the validationQuery parameter must be a non-empty string --> 
        < property name = "testOnBorrow" value = = "true" />  
        <!-- Used to verify whether the connection is valid before the connection is returned to the caller SQL statement, if an SQL statement is specified, it must be a SELECT statement with at least one row of results --> 
        < property name ="validationQuery" value ="select 1" />  
        <!-- The database where the connection pool is active The maximum number of connections, 0 means no limit, means maximum concurrency -->   
        < property name ="maxActive" value ="1000" />   
        <!-- Number of initialized connections --> 
        < property name ="initialSize" value="10"/> 
        <!-- When the connection in the connection pool is used up, the waiting time for a new request (that is, waiting for other connections to be idle), the timeout returns an exception, milliseconds -->  
        < property name ="maxWait" value ="100000" />   
        < !-- In milliseconds, it means that the idle object eviction process enters the running state from the sleep state. If the value is not positive, it means that no idle object eviction process is run.
         The interval for running the task of judging connection timeout --> 
        < property name ="timeBetweenEvictionRunsMillis" value ="30000" />  
        <!-- The minimum time in milliseconds that the connection remains idle in the pool before it is expelled by the idle object eviction process, Connection timeout, the default is half an hour --> 
        < property name ="minEvictableIdleTimeMillis" value ="30000" />  
        <!-- The connection pool checks the number of objects for each idle object eviction process
            <property name="numTestPerEvictionRun" value="3"/>
        -->         
        <!-- The minimum number of database connections in the idle state of the connection pool, below this value will create the lack of connections, set 0 to unlimited -->  
        < property name ="minIdle" value ="10" /> 
        <!-- The maximum number of database connections in the idle state of the connection pool, a non-positive integer means unlimited, excess idle connections will be released when this value is exceeded -->    
        < property name = "maxIdle" value ="200" /> 
        <!-- Whether the flag of clearing information is recorded in the log when clearing invalid connections --> 
         < property name ="logAbandoned" value ="false" />  
         <!-- whether clearing has exceeded removeAbandonedTimeout Invalid connection set, automatically recycle timeout connection
          Startup mechanism: getNumActive() > getMaxActive() - 3 and getNumIdle() < 2
          Assuming maxActive=20, and there are currently 18 active connections and 1 idle connection, the mechanism will start
          But only if the active connection has not been used for more than "removeAbandonedTimeout" (default 300 seconds), the connection will be cleared --> 
        < property name ="removeAbandoned" value ="true" />  
        <!-- Indicates that clearing is invalid in seconds Connection time limit, self-interruption time, in seconds -->          
        < property name ="removeAbandonedTimeout" value ="60" /> 
        <!-- Set the interceptor, the default is empty
         ConnectionState: Tracks autocommit, read-only directory and transaction isolation level
         StatementFinalizer: Tracks open statements and returns to the pool when the connection is closed
         --> 
        <property name="jdbcInterceptors" value="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"/>  
</bean> 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326990399&siteId=291194637