목차

BoneCP

설정 예(Spring)

<bean class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
   <property name="driverClass" value="#{driverClass}" />
   <property name="jdbcUrl" value="#{jdbcUrl}" />
   <property name="username" value="#{username}"/>
   <property name="password" value="#{password}"/>
   <property name="idleConnectionTestPeriodInSeconds" value="60"/>
   <property name="idleMaxAgeInSeconds" value="240"/>
   <property name="maxConnectionsPerPartition" value="#{maxConnectionsPerPartition}"/>
   <property name="minConnectionsPerPartition" value="#{minConnectionsPerPartition}"/>
   <property name="partitionCount" value="2"/>
   <property name="acquireIncrement" value="5"/>
   <property name="statementsCacheSize" value="100"/>
   <property name="releaseHelperThreads" value="3"/>
   <property name="connectionTimeoutInMs" value="10000"/>
   <property name="connectionTestStatement" value="/* ping */ select 1" />
</bean>

JMX MBean

0.8.RELEASE bug

WARN ConnectionPartition.finalizeReferent - BoneCP detected an unclosed connection (in pool 'pool name') and 
will now attempt to close it for you. You should be closing this connection in your application - enable 
connectionWatch for additional debugging assistance or set disableConnectionTracking to true to disable 
this feature entirely.

# 위 WARNING이 발생하면서 MySQL 사용시에 다음과 같은 오류가 연쇄 발생
....
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 
   No operations allowed after connection closed.

Bug #1259257 “BoneCP 0.8.0-release erroneously detecting unclose...” : Bugs : BoneCP 버그 리포팅 돼 있는 상태.

boneCpDataSource.setDisableConnectionTracking(true);로 문제 해결됨.

// Spring 등을 통해 connection release가 100% 보장되는 경우 다음처럼 커넥션 트랙킹을 disable.
boneCpDataSource.setDisableConnectionTracking(true);

// 다른곳에서의 해결책 : https://groups.google.com/forum/#!topic/play-framework/eshzvWuNQcc
boneCpDataSource.setStatisticsEnabled(true);
boneCpDataSource.setReleaseHelperThreads(2); // 이 값을 2로하면 문제가 사라진다 함.

Connection 끊김 문제