连接池中缺少什么参数?
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.idleConnectionTestPeriod">300</property>
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property> <!-- seconds -->
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">100</property> <!-- seconds -->
这是 hibernate.cfg.xml 中的配置。我正在使用 hibernate 3.2.5 和 c3p0 0.9。我不知道我在这个配置中错过了什么。经过几次请求后,它显示连接达到最大池大小并等待可用资源。如果我在本地计算机上没有连接池配置的情况下使用,它不会显示任何错误消息。 请帮我找出缺失的部分。
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.idleConnectionTestPeriod">300</property>
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property> <!-- seconds -->
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">100</property> <!-- seconds -->
This is the configuration in hibernate.cfg.xml. I am using hibernate 3.2.5 and c3p0 0.9. I don't know what i missed in this configuration. After few request, it show connection reached max pool size and waiting for free resources. If i use without connection pooling configuration in my local machine, it won't show any error message.
Please help me to find out the missing part.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用以下配置,它在长期测试中没有问题:
(我的数据源是由spring配置的,但无论如何你都可以看到c3p0的属性)
但是我猜你的问题不是配置。我假设并非所有连接都返回到池中,因此池在一段时间后就会耗尽。
I a using the following configuration an it is working without problems in long-run tests:
(My datasource is configured by spring, but you can see the properties for c3p0 anyway)
However I would guess your problem is not the configuration. I assume that not all connections are returned to the pool and so the pool runs dry after some time.