DBCP(http://commons.apache.org/dbcp/configuration.html) 페이지를 보면 설명이 나오는데. 이거 썩 설명이 많지 않다. 여기다가 사족을 붙이고자 한다. 


 initialSize 0 (디폴트 값)
The initial number of connections that are created when the pool is started.
Since: 1.2
초기화시 싱생되는 connection 수를 의미한다. 

maxActive 8 (디폴트값)
The maximum number of active
 connections that can be allocated from this pool at the same time, or negative for no limit.
동시에 동작 가능한 최대 connection 개수이며, 이 이상의 connection을 요구하면, 반환될때까지 lock이 걸린다. -값은 크기 제한이 없다 

maxIdle 8 (디폴트값)
The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
풀에서 idle를 유지하는 최대 개수를 의미한다.  -값은 크기 제한이 없다 

minIdle 0 (디폴트값)
The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.
풀에서 idle를 유지할 수 있는 최소의 connection를 의미한다. evictor가 쫓아내더라도 이 숫자는 보장한다.

maxWait (디폴트값)
indefinitely 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. 
Exception나기 전까지 풀에서 커넥션을 얻을때까지 얼마나 기다릴지를 지정한다.
보통 3000 이 좋은 값인듯.


파라미터

디폴트값

설명

validationQuery

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.

 

물려있는 connection validation 체크를 수행할 sql 문을 지정한다. 오라클의 경우는 select 1 from dual 이며, msql의 경우는 select 1 로 지정하는 경우가 많다.

testOnBorrow

true

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.
validationQuery
 connection이 살았나 죽었나 확인해준다.

NOTE - for a
true value to have any effect, the validationQuery parameter must be set to a non-null string.

 

pool에서 connection을 가져와서(borrow) connectionvalidationQuery를 실행한다.

testOnReturn

false

The indication of whether objects will be validated before being returned to the pool.
NOTE - for a
true value to have any effect, the validationQuery parameter must be set to a non-null string.

 

pool에서 connection을 돌려줄 때(return) connectionvalidationQuery를 실행한다.

testWhileIdle

false

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. NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
왕 중요하다.

Evitor threadIdle connection을 확인하여 connectionvalidationQuery를 체크하여 문제가 발생하면 connection pool에서 제거한다.

timeBetweenEvictionRunsMillis

-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. 
evictor thread
가 실행되는 주기를 의미한다. 단위는 millisecond이다. 그동안 6000으로 사용해왔다.

numTestsPerEvictionRun

3

The number of objects to examine during each run of the idle object evictor thread (if any).

Evitor thread 동작시 idle connection의 개수만큼 체크한다.

minEvictableIdleTimeMillis

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). 
디폴트는 30분이다. evictor요청이 오면 이 시간값을 기준으로 생성된지 오래된 idle connecion을 없앤다
DB
입장에서 보면, 한번 3개가 들어와 session에 대해서 soft parsing하는 쿼리문으로 보인다


if (evictor
요청시간 - idle 객체 생성된 시간
> minEvictableIdleTimeMillis) {
     connection
회수
()
}
Evictor
가 잘 일을 못한다고 해서 -1로 설정하고 있다


 

 

'general java' 카테고리의 다른 글

Notepad with class java file (Jad Usage Tip)  (0) 2009.04.17
java sources for ojdbc  (0) 2009.04.17
Jad 사용법  (0) 2009.04.10
JMX 개발중 POJO를 이용하기  (0) 2009.03.31
jdk 5,6 클래스를 jdk 3,4에서 실행하기  (0) 2009.03.30
Posted by '김용환'
,