简体   繁体   English

如何在应用程序启动时初始化 c3po 连接池?

[英]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.

相关问题 如果Mysql端口被阻止,如何防止应用程序(使用hibernate + c3po)挂起? - How to prevent application (using hibernate + c3po) from hanging if Mysql port is blocked? C3PO:客户端在等待获取资源时超时 - C3PO: A client timed out while waiting to acquire a resource 我的H2 / C3PO / Hibernate设置似乎没有保留预处理语句? - My H2/C3PO/Hibernate setup does not seem to preserving prepared statements? Hibernate / c3pO在Tomcat下不起作用-Windows 10:明显的死锁 - Hibernate/c3pO doesn't work under Tomcat - Windows 10: apparent deadlock 为什么同时使用C3PO和JNDI会产生问题? - Why does using C3PO and JNDI at the same time create an issue? Hibernate c3p0连接池初始化两次 - Hibernate c3p0 connection pool initialize twice Jpa Hibernate c3po。 连接是否断开? - Jpa Hibernate c3po. Is connection broken or not? 如何在Spring Boot休眠多租户应用程序中使用C3P0来管理连接池? - How to use C3P0 in a spring boot hibernate multi tenant application to manage connection pool? Google Cloud 数据流:如何为每个工作人员(单例)仅初始化一次 Hikari 连接池? - Google Cloud dataflow : How to initialize Hikari connection pool only once per worker (singleton)? 如何利用hibernate c3p0连接池? - How to utilize hibernate c3p0 connection pool?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM