2014-09-23 4 views
0

Guice/Mybatis를 사용하여 MySQL 데이터베이스에 대한 쿼리를 관리하고 실행합니다. 연결을 설정하고 MyBatisModule이 관련 비트를 포함 확장 내 클래스 :guice, mybatis 및 c3p0 또는 bonecp를 사용하여 연결 풀 크기 구성

Properties myBatisProperties = new Properties(); 
myBatisProperties.setProperty("c3p0.maxPoolSize", "5"); 
myBatisProperties.setProperty("c3p0.initialPoolSize", "5"); 
bindDataSourceProviderType(C3p0DataSourceProvider.class); 
bindTransactionFactoryType(JdbcTransactionFactory.class); 
addMapperClass(getMapperClass()); 
Names.bindProperties(binder(), myBatisProperties); 
bind(getBindServiceClass()).to(getBindServiceToClass()); 

내가 bonecp.maxConnectionsPerPartitionbonecp.partitionCountC3p0DataSourceProvider의 장소에서 적절한 DataSourceProvider.class의 속성을 사용하여 두 C3P0를 C3P0 또는 bonecp를 사용하거나 구성하고 bonecp는 나의 최대 연결 설정을 무시하고 mysql이 가능한 연결을 다 쓸 때까지 모든 쿼리에 대해 새로운 연결을 열어 놓는다.

기본 mybatis 풀 공급자 PooledDataSourceProvider 및 해당 속성 인 mybatis.pooled.maximumActiveConnectionsmybatis.pooled.maximumIdleConnections을 사용할 때 내 구성 및 풀 연결을 올바르게 준수합니다.

내가 뭘 잘못하고 있니? 이것에 대한

또한 문서는 문제가 나의 새로운 인젝터를 만들 때마다 때문처럼 보이는 http://mybatis.github.io/guice/datasources.html

+0

re c3p0 : c3p0은 풀 초기화시 INFO에서 구성을 덤프합니다. 로그를 확인하고 원하는 설정이 DataSource에 적용되었는지 확인하십시오. 그렇지 않다면 c3p0을 사용하는 래퍼를 통해 구성하는 것보다 많은 다른 방법이 있습니다. –

+0

이상한 ... 3cp0은 최대 풀 크기가 5라고 주장합니다. [acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0 forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 5, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 5, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3 , numHelperThreads -> 3, unreturnedConnectionTimeout -> 0]' – Supagoat

+0

(주석 크기 제한에 맞게 몇 가지를 삭제했습니다. 거기에 보이지 않는 내용이 있으면 알려 주시기 바랍니다) – Supagoat

답변

0

에서 확인할 수있다. 특히이 라인 : 대신 내가 인젝터에게 싱글을하면

Injector injector = Guice.createInjector(new MyDAOPoolModule()); return injector.getInstance(MyDAOService.class);

, 그것은 단지 하나 개의 풀을 생성합니다.