tomcat連接池之context.xml中屬性探索

tomcat配置中是可以在context.xml中配置數據庫連接池相關信息的,tomcat中間件通過自己的tomcat-jdbc.jar包實現了jdbc數據庫的連接,有時我們不緊想知道那幾個基礎配置信息,還想深入瞭解其他配置屬性。這時我們去tomcat lib目錄下尋找答案。

找到tomcat-jdbc.jar打開來,裏面org\apache\tomcat\jdbc\pool目錄下有我們要找的答案,mbeans-descriptors.xml ,通過裏面的英文註釋我們可以詳細得知具體配置屬性。

<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<mbeans-descriptors>

    <mbean        name="TomcatJDBCPool"
           description="Provides per diagnostic metrics and notifications for JDBC operations"
                domain="tomcat"
                 group="jdbc"
                  type="org.apache.tomcat.jdbc.pool.DataSource">

    <attribute    name="className"
           description="Fully qualified class name of the managed object"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="size"
           description="The number of established connections in the pool, idle and in use"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="idle"
           description="The number of established connections in the pool that are idle"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="numIdle"
           description="Same as the idle attribute"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="active"
           description="The number of established connections in the pool that are in use"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="numActive"
           description="Same as the active attribute"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="poolSweeperEnabled"
           description="Returns true if the pool has a background thread running"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="url"
           description="The JDBC url for this connection pool"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="driverClassName"
           description="The JDBC driver class for this connection pool"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="defaultAutoCommit"
           description="The JDBC auto commit setting for new connections"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="defaultReadOnly"
           description="The JDBC read only setting for new connections"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="defaultTransactionIsolation"
           description="The JDBC transaction isolation setting for new connections"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="connectionProperties"
           description="The connection properties that will be set for new connections. Format of the string will be [propertyName=property;]*"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="defaultCatalog"
           description="The JDBC transaction isolation setting for new connections"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="initialSize"
           description="The number of connections opened at pool startup"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="maxActive"
           description="The maximum number of open connections"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="maxIdle"
           description="The max number of idle connections"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="minIdle"
           description="The minimum number of open connections"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="maxWait"
           description="The time to wait in milliseconds before a SQLException is thrown when a connection is requested"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="validationQuery"
           description="The query to run during validation"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="validationQueryTimeout"
           description="The timeout in seconds before a connection validation queries fail"
                  type="java.lang.Integer"
             writeable="false" />

    <attribute    name="testOnBorrow"
           description="True if validation happens when a connection is requested"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="testOnReturn"
           description="True if validation happens when a connection is returned"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="testWhileIdle"
           description="True if validation happens when a connection is not in use (idle)"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="timeBetweenEvictionRunsMillis"
           description="Sleep time for background thread in between pool checks"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="numTestsPerEvictionRun"
           description="Not in use"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="minEvictableIdleTimeMillis"
           description="Minimum amount of time a connection stays idle before it is evicted"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="accessToUnderlyingConnectionAllowed"
           description="Returns true if one can retrieve the actual JDBC connection"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="removeAbandoned"
           description="Returns true if connection in use can be timed out"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="removeAbandonedTimeout"
           description="Timeout in seconds for connections in use"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="logAbandoned"
           description="If true, stack trace will be recorded and printed out for timed out connection"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="loginTimeout"
           description="Not in use"
                  type="java.lang.Integer"
             writeable="false"/>


    <attribute    name="name"
           description="The name of the connection pool, will be used in the ObjectName of the actual pool"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="password"
           description="For security purposes,this doesn't return anything"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="username"
           description="The username used to open connections"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="validationInterval"
           description="If larger than zero than validation will only occur after the interval milliseconds has passed"
                  type="java.lang.Long"
             writeable="false"/>

    <attribute    name="initSQL"
           description="A SQL executed once per connection, when it is established"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="testOnConnect"
           description="Validate connection after connection has been established"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="jdbcInterceptors"
           description="The interceptors configured for this pool"
                  type="java.lang.String"
             writeable="false"/>

<attribute    name="jmxEnabled"
           description="Register the pool with JMX or not"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="fairQueue"
           description="a fair queue is being used by the connection pool"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="abandonWhenPercentageFull"
           description="Connections that have been abandoned isn't closed unless connections in use are above this percentage"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="maxAge"
           description="Time in milliseconds to keep this connection alive even when used"
                  type="java.lang.Long"
             writeable="false"/>

    <attribute    name="useEquals"
           description="Set to true if you wish the ProxyConnection class to use String.equals and set to false when you wish to use == when comparing method names"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="useLock"
           description="If true, use a lock when operations are performed on the connection object"
                  type="java.lang.Boolean"
                    is="false"
             writeable="false"/>

    <attribute    name="suspectTimeout"
           description="Timeout in seconds for connection that suspected to have been abandoned"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="rollbackOnReturn"
           description="If autoCommit==false then the pool can terminate the transaction by calling rollback on the connection as it is returned to the pool"
                  type="java.lang.Boolean"
                    is="false"
             writeable="false"/>

    <attribute    name="commitOnReturn"
           description="If autoCommit==false then the pool can complete the transaction by calling commit on the connection as it is returned to the pool"
                  type="java.lang.Boolean"
                    is="false"
             writeable="false"/>

    <attribute    name="alternateUsernameAllowed"
           description="If true, getConnection(username,password) is allowed"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <attribute    name="dataSource"
           description="Data source that is injected into the pool"
                  type="javax.sql.DataSource"
             writeable="false"/>

    <attribute    name="dataSourceJNDI"
           description="The JNDI name for a data source to be looked up"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="useDisposableConnectionFacade"
           description="If true, connection pool is configured to use a connection facade to prevent re-use of connection after close() has been invoked"
                  type="java.lang.Boolean"
                    is="false"
             writeable="false"/>

    <attribute    name="logValidationErrors"
           description="Log errors during the validation phase to the log file"
                  type="java.lang.Boolean"
                    is="false"
             writeable="false"/>

    <attribute    name="validatorClassName"
           description="The name of validator class which implements org.apache.tomcat.jdbc.pool.Validator interface"
                  type="java.lang.String"
             writeable="false"/>

    <attribute    name="waitCount"
           description="The number of threads waiting for a connection"
                  type="java.lang.Integer"
             writeable="false"/>

    <attribute    name="propagateInterruptState"
           description="If true, propagate the interrupt state for a thread that has been interrupted"
                  type="java.lang.Boolean"
                    is="false"
             writeable="false"/>

    <attribute    name="ignoreExceptionOnPreLoad"
           description="If true, ignore error of connection creation while initializing the pool"
                  type="java.lang.Boolean"
                    is="true"
             writeable="false"/>

    <operation    name="checkIdle"
                  description="forces a check of idle connections"
                  impact="ACTION"
                  returnType="void" />

    <operation    name="checkAbandoned"
                  description="forces a check of abandoned connections"
                  impact="ACTION"
                  returnType="void" />

    <operation    name="testIdle"
                  description="forces a validation of abandoned connections"
                  impact="ACTION"
                  returnType="void" />

    <operation    name="purge"
                  description="Purges all connections in the pool"
                  impact="ACTION"
                  returnType="void" />

    <operation    name="purgeOnReturn"
                  description="Purges connections when they are returned from the pool"
                  impact="ACTION"
                  returnType="void" />

  </mbean>

</mbeans-descriptors>


發佈了93 篇原創文章 · 獲贊 133 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章