Hibernate配置连接池大小 [英] Hibernate config connection pool size

查看:658
本文介绍了Hibernate配置连接池大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在连接池的hibernate配置文件中设置10? size = 1是为size.why需要增加尺寸吗?



 <!DOCTYPE hibernate-configuration PUBLIC 
- // Hibernate / Hibernate配置DTD 3.0 // EN
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">

< hibernate-configuration>

< session-factory>
....

< property name =connection.pool_size> 10< / property>

....
< / session-factory>

< / hibernate-configuration>


解决方案

Hibernate API 文档。


然而,Hibernate自己的连接池算法相当简陋。它旨在帮助您开始使用,不适用于生产系统,甚至不适用于性能测试。您应该使用第三方池以获得最佳性能和稳定性。只需将hibernate.connection.pool_size属性替换为连接池特定的设置即可。这将关闭Hibernate的内部池。例如,您可能想使用c3p0。


connection.pool_size 表示连接池的最大数量。所以最好把它保持在逻辑上。这取决于你的应用程序和数据库能处理多少。 10 是一个合理的计数,通常用于大多数情况。


why set 10 in hibernate config file for connection pooling ? size = 1 is built in size.why need to increase size ?

<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

    <session-factory>
     ....

       <property name="connection.pool_size">10</property>

     ....
    </session-factory>

</hibernate-configuration>

解决方案

From the Hibernate API Docs.

Hibernate's own connection pooling algorithm is, however, quite rudimentary. It is intended to help you get started and is not intended for use in a production system, or even for performance testing. You should use a third party pool for best performance and stability. Just replace the hibernate.connection.pool_size property with connection pool specific settings. This will turn off Hibernate's internal pool. For example, you might like to use c3p0.

connection.pool_size indicates the maximum number of pooled connections. So it is better to keep it at a logical count. It depends on your application and DB how much it can handle. 10 is a reasonable count that will typically used as it is sufficient for most cases.

这篇关于Hibernate配置连接池大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆