问题描述
我正在使用Hibernate,并且已经按照。示例配置如下:
I am using Hibernate and I have configured some c3p0 properties in its config as specified in one of the hibernate documentation. Sample configuration looks like :
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
我知道c3p0还有许多其他属性可以通过配置文件c3p0.properties进行设置,但是无法通过中的initialPoolSize,maxStatementsPerConnection,acquireRetryAttempts等休眠配置进行设置。
I came to know that c3p0 has many other properties that can be set via configuration file c3p0.properties but cannot be set via hibernate configuration like initialPoolSize, maxStatementsPerConnection, acquireRetryAttempts, etc in c3p0 Documentation.
我的问题是如何验证在c3p0.properties中设置的属性是否被实际使用?一种解决方案是启用日志到调试级别。还有其他解决方案可以确认这一点吗?像是通过编程来学习
My question is how can I verify if the properties I am setting in c3p0.properties are actually being used? One solution can be to enable log to debug level. Is there any other solution to confirm this? like may be via some class programmatically.
推荐答案
您无需在C3P0配置文件中进行设置。您可以将任何C3P0配置传递给Hibernate的配置,因为Hibernate会以前缀为C3P0。
You don't need to set them in a C3P0 configuration file. You can pass any C3P0 configuration to Hibernate's config, since Hibernate passes all settings starting with the hibernate.c3p0 prefix to C3P0.
因此,您可以摆脱 c3p0 .properties
并只需添加新设置:
So, you can get rid of c3p0.properties
and simply add new settings:
<property name="hibernate.c3p0.initialPoolSize">1</property>
<property name="hibernate.c3p0.maxStatementsPerConnection">10</property>
<property name="hibernate.c3p0.acquireRetryAttempts">5</property>
要查看C3P0配置,可以使用。如果您想监视连接池的使用情况并为无法预料的流量高峰提供回退机制,则应查看。
To see C3P0 configurations you can use a JMX client. If you want to monitor the connection pool usage and also provide a fall-back mechanism for unforeseen traffic spikes, then you should take a look at FlexyPool.
这篇关于使用Hibernate配置c3p0属性initialPoolSize和maxStatements的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!