<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>
idleMaxAge
는 idleConnectionTestPeriod
보다 커야한다. 그렇지 않으면 idleMaxAge에 도달하면 커넥션을 끊어버리기 때문에 실제로 idleConnectionTestPeriod
는 사실상 필요가 없어지게 된다.setPoolName()
으로 지정한 이름이된다.boneCpDataSource.getConnection()
이 한 번이라도 호출이 되어야만 MBean이 생성된다.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로하면 문제가 사라진다 함.
Database access problem. Killing off this connection and all remaining connections in the connection pool. SQL State = 08007 Communications link failure during rollback(). Transaction resolution unknown.