[英]How to initialize c3po connection pool on application launch?
c3p0
connection pool initialize when I perform some JPA
operation, it takes 2 seconds to initialize.当我执行一些JPA
操作时, c3p0
连接池初始化,初始化需要 2 秒。
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.idle_test_period">150</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.privilegeSpawnedThreads">true</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
So is there a way to do it on application launch?那么有没有办法在应用程序启动时做到这一点?
Perform an operation on application startup.在应用程序启动时执行操作。
If your c3p0 DataSource
is called myPool
, then myPool.getConnection().close()
is sufficient.如果您的 c3p0 DataSource
被称为myPool
,那么myPool.getConnection().close()
就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.