属性(Parameter)
|
默认值(Default)
|
描述(Description)
|
username
|
|
传递给JDBC驱动的用于建立连接的用户名(The connection username to be passed to our JDBC driver to establish a connection.)
|
password
|
|
传递给JDBC驱动的用于建立连接的密码(The connection password to be passed to our JDBC driver to establish a connection.)
|
url
|
|
传递给JDBC驱动的用于建立连接的URL(The connection URL to be passed to our JDBC driver to establish a connection.)
|
driverClassName
|
|
使用的JDBC驱动的完整有效的java 类名(The fully qualified Java class name of the JDBC driver to be used.)
|
defaultAutoCommit
|
driver default
|
连接池创建的连接的默认的auto-commit状态,没有设置则不会自动提交(The default auto-commit state of connections created by this pool. If not set then the setAutoCommit method will
not be called.)
|
initialSize
|
0
|
初始化连接:连接池启动时创建的初始化连接数量(The initial number of connections that are created when the pool is started.
|
maxTotal
|
8
|
最大活动连接:连接池在同一时间能够分配的最大活动连接的数量, 如果设置为非正数则表示不限制(The maximum number of active connections that can be allocated from this pool at the same time, or negative
for no limit.)
|
maxIdle
|
8
|
最大空闲连接:连接池中容许保持空闲状态的最大连接数量,超过的空闲连接将被释放,如果设置为负数表示不限制(The maximum number of connections that can remain idle in the pool, without extra ones being released,
or negative for no limit.)
|
minIdle
|
0
|
最小空闲连接:连接池中容许保持空闲状态的最小连接数量,负数表示没有现在(The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative
for no limit.)
|
注意:如果在某些负载比较大的系统中将maxIdel设置过小时,很可能会出现连接关闭的同时新连接马上打开的情况.这是由于关闭连接的线程比打开的快导致的.所以,对于这种系统中,maxIdle的设定值是不同的但是通常首选默认值
|
(NOTE: If maxIdle is set too low on heavily loaded systems it is possible you will see connections being closed and almost immediately new connections being
opened. This is a result of the active threads momentarily closing connections faster than they are opening them, causing the number of idle connections to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is
a good starting point.)
|
maxWaitMillis
|
indefinitely
|
最大等待时间:当没有可用连接时,连接池等待连接被归还的最大时间(以毫秒计数),超过时间则抛出异常,如果设置为-1表示无限等待(The maximum number of milliseconds that the pool will wait (when there are no available
connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.)
|
validationQuery
|
|
SQL查询,用来验证从连接池取出的连接,在将连接返回给调用者之前.如果指定,则查询必须是一个SQL SELECT并且必须返回至少一行记录(The SQL query that will be used to validate connections from this pool before
returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified, connections will be validation by calling the isValid() method.)
|
testOnCreate
|
false
|
指明是否在建立连接之后进行验证,如果验证失败,则尝试重新建立连接(The indication of whether objects will be validated after creation. If the object fails to validate, the borrow attempt
that triggered the object creation will fail.)
|
testOnBorrow
|
true
|
指明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个. 注意: 设置为true后如果要生效,validationQuery参数必须设置为非空字符串(The indication of whether objects will be validated before
being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.)
|
testOnReturn
|
false
|
指明是否在归还到池中前进行检验(The indication of whether objects will be validated before being returned to the pool.)
|
testWhileIdle
|
false
|
指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除. 注意: 设置为true后如果要生效,validationQuery参数必须设置为非空字符串(The indication of whether objects will be validated by the
idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.)
|
timeBetweenEviction-
RunsMillis
|
-1
|
在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位.如果设置为非正数,则不运行空闲连接回收器线程(The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive,
no idle object evictor thread will be run.)
|
numTestsPerEvictionRun
|
3
|
在每次空闲连接回收器线程(如果有)运行时检查的连接数量(The number of objects to examine during each run of the idle object evictor thread (if any).)
|
minEvictableIdleTime-Millis
|
1000*60*30
|
连接在池中保持空闲而不被空闲连接回收器线程(如果有)回收的最小时间值,单位毫秒(The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle
object evictor (if any).)
|
softMiniEvictableIdle- TimeMillis
|
-1
|
说明(The minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle connection evictor, with the extra
condition that at least "minIdle" connections remain in the pool. When miniEvictableIdleTimeMillis is set to a positive value, miniEvictableIdleTimeMillis is examined first by the idle connection evictor - i.e. when idle connections are visited by the evictor,
idle time is first compared against miniEvictableIdleTimeMillis (without considering the number of idle connections in the pool) and then against softMinEvictableIdleTimeMillis, including the minIdle constraint.)
|
maxConnLifetimeMillis
|
-1
|
说明(The maximum lifetime in milliseconds of a connection. After this time is exceeded the connection will fail the next activation, passivation or validation
test. A value of zero or less means the connection has an infinite lifetime.)
|
logExpiredConnections
|
true
|
说明(Flag to log a message indicating that a connection is being closed by the pool due to maxConnLifetimeMillis exceeded. Set this property to false
to suppress expired connection logging that is turned on by default.
|
connectionInitSqls
|
null
|
说明(A Collection of SQL statements that will be used to initialize physical connections when they are first created. These statements are executed only
once - when the configured connection factory creates the connection.)
|
info
|
true
|
说明(True means that borrowObject returns the most recently used ("last in") connection in the pool (if there are idle connections available). False
means that the pool behaves as a FIFO queue - connections are taken from the idle instance pool in the order that they are returned to the pool.)
|
poolPreparedState-ments
|
false
|
开启池的prepared statement 池功能(Enable prepared statement pooling for this pool.)
|
maxOpenPreparedState-ments
|
unlimited
|
statement池能够同时分配的打开的statements的最大数量, 如果设置为0表示不限制(The maximum number of open statements that can be allocated from the statement pool at the same time,
or negative for no limit.)
|
NOTE - Make sure your connection has some resources left for the other statements. Pooling PreparedStatements may keep their cursors open in the database,
causing a connection to run out of cursors, especially if maxOpenPreparedStatements is left at the default (unlimited) and an application opens a large number of different PreparedStatements per connection. To avoid this problem, maxOpenPreparedStatements
should be set to a value less than the maximum number of cursors that can be open on a Connection.
|
accessToUnderlyingConnectionAllowed
|
false
|
控制PoolGuard是否容许获取底层连接(Controls if the PoolGuard allows access to the underlying connection.) 默认false不开启, 这是一个有潜在危险的功能, 不适当的编码会造成伤害.(关闭底层连接或者在守护连接已经关闭的情况下继续使用它).请谨慎使用,并且仅当需要直接访问驱动的特定功能时使用.注意: 不要关闭底层连接, 只能关闭前面的那个. Default
is false, it is a potential dangerous operation and misbehaving programs can do harmful things. (closing the underlying or continue using it when the guarded connection is already closed) Be careful and only use when you need direct access to driver specific
extensions. NOTE: Do not close the underlying connection, only the original one.
|
removeAbandoned
|
false
|
标记是否删除泄露的连接,如果他们超过了removeAbandonedTimout的限制.如果设置为true, 连接被认为是被泄露并且可以被删除,如果空闲时间超过removeAbandonedTimeout. 设置为true可以为写法糟糕的没有关闭连接的程序修复数据库连接. (Flags to
remove abandoned connections if they exceed the removeAbandonedTimout. A connection is considered abandoned and eligible for removal if it has not been used for longer than removeAbandonedTimeout. Setting one or both of these to true can recover db connections
from poorly written applications which fail to close connections.)
|
removeAbandonedTimeout
|
300
|
泄露的连接可以被删除的超时值, 单位秒 (Timeout in seconds before an abandoned connection can be removed.)
|
logAbandoned
|
false
|
标记当Statement或连接被泄露时是否打印程序的stack traces日志。被泄露的Statements和连接的日志添加在每个连接打开或者生成新的Statement,因为需要生成stack trace。(Flag to log stack traces for application code
which abandoned a Statement or Connection. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.)
|
abandonedUsageTracking
|
false
|
如果为true, 那么连接池会记录每个方法调用时候的堆栈信息以及废弃连接的调试信息(If true, the connection pool records a stack trace every time a method is called on a pooled connection and
retains the most recent stack trace to aid debugging of abandoned connections. There is significant overhead added by setting this to true.)
|
注:如果开启"removeAbandoned",那么连接在被认为泄露时可能被池回收. 这个机制在(getNumIdle() < 2)and (getNumActive() > getMaxActive() - 3)时被触发. 举例当maxActive=20, 活动连接为18,空闲连接为1时可以触发"removeAbandoned".但是活动连接只有在没有被使用的时间超过"removeAbandonedTimeout"时才被删除,默认300秒.在resultset中游历不被计算为被使用.
|
If you have enabled removeAbandonedOnMaintenance or removeAbandonedOnBorrow then it is possible that a connection is reclaimed by the pool because it is considered to be abandoned. This mechanism
is triggered when (getNumIdle() < 2) and (getNumActive() > getMaxTotal() - 3) and removeAbandonedOnBorrow is true; or after eviction finishes and removeAbandonedOnMaintenance is true. For example, maxTotal=20 and 18 active connections and 1 idle connection
would trigger removeAbandonedOnBorrow, but only the active connections that aren't used for more then "removeAbandonedTimeout" seconds are removed (default 300 sec). Traversing a resultset doesn't count as being used. Creating a Statement, PreparedStatement
or CallableStatement or using one of these to execute a query (using one of the execute methods) resets the lastUsed property of the parent connection.
|