DBCP2


ParameterDescription
usernameThe connection username to be passed to our JDBC driver to establish a connection.
passwordThe connection password to be passed to our JDBC driver to establish a connection.
urlThe connection URL to be passed to our JDBC driver to establish a connection.
driverClassNameThe fully qualified Java class name of the JDBC driver to be used.
connectionPropertiesThe connection properties that will be sent to our JDBC driver when establishing new connections.
Format of the string must be [propertyName=property;]*
NOTE - The "user" and "password" properties will be passed explicitly, so they do not need to be included here.

ParameterDefaultDescription
defaultAutoCommitdriver defaultThe default auto-commit state of connections created by this pool. If not set then the setAutoCommit method will not be called.
defaultReadOnlydriver defaultThe default read-only state of connections created by this pool. If not set then the setReadOnly method will not be called. (Some drivers don't support read only mode, ex: Informix)
defaultTransactionIsolationdriver defaultThe default TransactionIsolation state of connections created by this pool. One of the following: (see javadoc)
  • NONE
  • READ_COMMITTED
  • READ_UNCOMMITTED
  • REPEATABLE_READ
  • SERIALIZABLE
defaultCatalog
The default catalog of connections created by this pool.
cacheStatetrueIf true, the pooled connection will cache the current readOnly and autoCommit settings when first read or written and on all subsequent writes. This removes the need for additional database queries for any further calls to the getter. If the underlying connection is accessed directly and the readOnly and/or autoCommit settings changed the cached values will not reflect the current state. In this case, caching should be disabled by setting this attribute to false.

ParameterDefaultDescription
initialSize0The initial number of connections that are created when the pool is started.
Since: 1.2
maxTotal8The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
maxIdle8The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
minIdle0The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.
maxWaitMillisindefinitelyThe 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.
 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.

ParameterDefaultDescription
validationQuery
The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this queryMUST be an SQL SELECT statement that returns at least one row. If not specified, connections will be validation by calling the isValid() method.
testOnCreatefalseThe 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.
testOnBorrowtrueThe 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.
testOnReturnfalseThe indication of whether objects will be validated before being returned to the pool.
testWhileIdlefalseThe 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.
timeBetweenEvictionRunsMillis-1The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.
numTestsPerEvictionRun3The number of objects to examine during each run of the idle object evictor thread (if any).
minEvictableIdleTimeMillis1000 * 60 * 30The 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).
softMiniEvictableIdleTimeMillis-1The 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-1The 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.
connectionInitSqlsnullA 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.
lifotrueTrue 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.

ParameterDefaultDescription
poolPreparedStatementsfalseEnable prepared statement pooling for this pool.
maxOpenPreparedStatementsunlimitedThe maximum number of open statements that can be allocated from the statement pool at the same time, or negative for no limit.
 This component has also the ability to pool PreparedStatements. When enabled a statement pool will be created for each Connection and PreparedStatements created by one of the following methods will be pooled:
  • public PreparedStatement prepareStatement(String sql)
  • public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
 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.

ParameterDefaultDescription
accessToUnderlyingConnectionAllowedfalseControls if the PoolGuard allows access to the underlying connection.
 Default is false, it is a potential dangerous operation and misbehaving programs can do harmfull things. (closing the underlying or continue using it when the guarded connection is already closed) Be carefull and only use when you need direct access to driver specific extentions.
 NOTE: Do not close the underlying connection, only the original one.

ParameterDefaultDescription
removeAbandonedfalseFlag to remove abandoned connections if they exceed the removeAbandonedTimout.
If set to true a connection is considered abandoned and eligible for removal if it has not been used for longer than the removeAbandonedTimeout.
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.
Setting this to true can recover db connections from poorly written applications which fail to close a connection.
removeAbandonedTimeout300Timeout in seconds before an abandoned connection can be removed.
logAbandonedfalseFlag 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.
 If you have enabled "removeAbandoned" 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)
 For example, maxTotal=20 and 18 active connections and 1 idle connection would trigger the "removeAbandoned". 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.






속성기본값설명
initialSize0풀 시작 시 만들 Connection 개수
maxTotal8최대 활성 Connection 개수
0 이하의 값은 무한대를 의미 함
minIdle0대기 중인 Connection의 최소 개수
maxIdle8대기 중인 Connection의 최대 개수
0 이하의 값은 무한대를 의미 함
maxWaitMillis-1사용 가능한 Connection이 없을 때 어느 정도의 시간 후에 예외처리를 할 지 결정
-1은 무한대를 의미 함



validationQuery 
Connection 유효성 검사시에 사용할 쿼리문
* Oracle : select * from dual
* MySql : select 1
testOnCreatefalse+ Connection 생성 시 유효성 검사 여부
testOnBorrow true+ 풀에서 Connection을 가져올 때 유효성 검사 여부
testOnRetrunfalse+ Connection을 풀에 반환 할 때 유효성 검사 여부
testWhileIdlefalse비활성 Connection에 대한 유효성 검사 여부. Evictor 쓰레드에서 처리하며, 유효성 검사에 실패하면 해당 Connection을 풀에서 제거 함.
timeBetweenEvictionRunsMillis-1 대기 중인 Connection 제거 쓰레드(Evictor 쓰레드)의 활성화 간격
0 이하인 경우 Evictor 쓰레드가 동작하지 않는다.
numTestsPerEvictionRun3Evictor 쓰레드 한번에 테스트할 비활성 Connection의 갯수
minEvictableIdleTimeMillis1000 * 60 * 30Evictor 쓰레드의 제거 대상이 되기 위한 최소 비활성 대기 시간
softMiniEvictableIdleTimeMilles-1Evictor 쓰레드의 제거 대상이 되기 위한 최소 비활성 대기 시간. 단, minEvictableIdleTimeMilles가 우선 적용된다.



maxConnLifetimeMillis-1일정 시간 후 Connection을 더 이상 사용할 수 없게 만듬. 해당 Connection은 유효성 검사시 무조건 실패하게 되며, 활성화가 불가능 함.
0 이하의 값은 무한대를 의미 함.
logExpiredConnectionstruemaxConnLifetimeMilles이 적용되어 Connection이 닫힐 때 로그를 남길 지 여부
connectionInitSqlsnullConnection 생성 시 실행할 SQL문
lifotrue풀을 스택 방식으로 운용
false인 경우는 큐 방식으로 운용



poolPreparedStatementsfalsePrepared Statement 풀링 여부
maxOpenPreparedStatements-1풀링할 Prepared Statement 개수 제한
0 이하의 값은 무한대를 의미 함



accessToUnderlyingConnectionAllowedfalseControls if the PoolGuard allows access to the underlying connection.
Underlying Connection이 뭔지를 모르겠네요;;



removeAbandonedOnMaintenancefalse Evictor 쓰레드가 돌 때 Abandoned 상태인 Connection을 제거할 지 여부
removeAbandonedOnBorrowfalse
Connection을 빌려줄 때 Abandoned 상태인 Connection을 제거할 지 여부. 추가로 아래 조건도 만족해야 함
  1. getNumActive() > getMaxTotal() – 3 AND
  2. getNumIdle() < 2
removeAbandonedTimeout300Abandoned 상태인 Connection을 제거하기 전에 기다릴 시간
logAbandonedfalse Abandoned 상태인 Connection을 제거할 때 로그를 남길 지 여부



fastFailValidationfalseJDBC 드라이버의 isValid 메서드 실행이나 요효성 검사 없이 SQL_STATE 코드만으로 빠르게 연결 실패 여부를 결정한다.
disconnectionSqlCodes가 없을 경우엔 아래의 SQL_STATE 코드로 연결 실패 여부를 결정한다.
  • 57P01 (ADMIN SHUTDOWN)
  • 57P02 (CRASH SHUTDOWN)
  • 57P03 (CANNOT CONNECT NOW)
  • 01002 (SQL92 disconnect error)
  • JZ0C0 (Sybase disconnect error)
  • JZ0C1 (Sybase disconnect error)
  • Any SQL_STATE code that starts with "08"

disconnectionSqlCodesnull연결 실패로 간주할 SQL_STATE 코드 목록.
fastFailValidation이 true인 경우에만 동작한다.

댓글

이 블로그의 인기 게시물

내부망에서 SBT 사용법

groupadd