简体   繁体   English

如果使用数据源,请休眠“ connection.pool_size”属性

[英]Hibernate “connection.pool_size” property in case of using datasource

I am using hibernate 4.0.1 in my Portlet application which deployed on Websphere application server, I am referring to datasource configured on the application server from the hibernate configuration, my question is should I use "connection.pool_size" property OR "c3p0" to set the connection pool size or no ? 我正在Websphere应用程序服务器上部署的Portlet应用程序中使用hibernate 4.0.1,我是指从hibernate配置在应用程序服务器上配置的数据源,我的问题是我应该使用“ connection.pool_size”属性还是“ c3p0”来设置连接池大小或否? , As the data source on server already have connection pool size with 10. ,因为服务器上的数据源已经具有10的连接池大小。

In other words, Which take the priority, the Hibernate configuration or the datasource configuration for connection pooling and which is better ? 换句话说,哪个优先使用Hibernate配置或用于连接池的数据源配置,哪个更好?

Thanks in advance. 提前致谢。

Datasource makes limitation for incoming connections. 数据源限制了传入连接。 If you use CP with for example 20 connections - maximum it will get 10 connections from 20. So your dsource pool size should be 20 or more. 例如,如果您使用CP进行20个连接-最多可以从20个连接中获得10个连接,那么您的源池大小应为20或更大。

When using a data source configured in WebSphere Application Server, which you access by JNDI name, either directly or by providing the JNDI name to your Hibernate config, you end up with connections being pooled by the application server by default. 当使用在WebSphere Application Server中配置的数据源(通过JNDI名称直接访问或通过将JNDI名称提供给Hibernate配置访问)时,默认情况下,连接最终将由应用程序服务器池化。 In additional to connection pooling, you also gain transaction enlistment, connection sharing, statement caching and other value adds. 除了连接池外,您还可以获得事务登记,连接共享,语句缓存和其他增值。 The application server does not detect the presence of alternate connection pooling and disable its own. 应用程序服务器不会检测到备用连接池,并禁用其自身。 Regarding your question about priority, neither takes priority. 关于优先权的问题,都不优先。 If a data source or other implementation provides its own connection pooling, you would end up with pooling being done at both layers, which is likely undesirable. 如果数据源或其他实现提供了自己的连接池,则最终将在两层进行池化,这可能是不可取的。 If you need to or prefer to, it is possible to manually disable the application server's connection pooling and statement caching while preserving the other capabilities that the application server provides (transaction enlistment and so forth) by setting the connection pool's aged timeout to immediate and the data source's statementCacheSize to 0. This would allow you to try with either implementation and judge for yourself which performs better in your particular scenario. 如果需要或愿意,可以通过将连接池的过期超时设置为即时和保留,来手动禁用应用程序服务器的连接池和语句缓存,同时保留应用程序服务器提供的其他功能(事务登记等)。数据源的statementCacheSize设置为0。这将允许您尝试使用任何一种实现并自己判断在特定情况下哪种性能更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM