开发者

Initializing c3p0 pools with different datasources

,Good day everyone!

I had an requirement to use several databases in application. In spring configuration file I configure two data sources each for separate database.

<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">someproperties here<bean/>
<bean id="myDataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">someproperties here<bean/>

<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="myDataSource" /> 

<bean id="mySessionFactory2" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource2" ref="myDataSource2" /> 

So I configured all datasources and then I wrote some simple test to check spring application context loading. I start that test and it runs awful long time (110 sec). In the logs i can see that pools are initialized 4 times.

INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [parameters...

Tried to remove datasource - now there is 2 pools initialization in log file, first initialization took 4-6 seconds , second approximatively 30-32...

Could someone give me a hint how can i fix that performance problem?

P.S. Mysql db 5开发者_高级运维.1, c3p0 version 0.9.1.2 (i tried 0.9.2 also), Spring 3.0.4, Hibernate 3.6

EDIT: I found that in my test - application context was started 2 times, so I suggest that was the reason why pools was initialized 4 times instead of 2, but still I have a performance issue pool for first datasource is initialized in 8 seconds, but pool for second datasource initialization time is 30-32 seconds...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜