hibernate default connection pooling

痞子三分冷 提交于 2019-11-28 02:40:52

问题


Does Hibernate use connection pool by default? If so what is the default value for *connection.pool_size*? Doesn't it conflicts with *hibernate.connection.release_mode*? Isn't the all idea of connection pooling is not closing connections?


回答1:


The default hibernate connection pool (which shouldn't be used in production) has a default limit of 1, since it is meant to just be used for simple testing. However this is configurable through the hibernate.properties file, so it's worth checking to see if it's defined there in your project.

The property in question is:

hibernate.connection.pool_size

Information on this is largely contained in this link:

http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html

While this doesn't directly specify the default connection pool size, it does have most of the information you could want on the subject of connection pooling in hibernate.




回答2:


By default, Hibernate ships with the ability to obtain a data source implementation ( javax.sql.DataSource ) from JNDI by setting the properties appropriately:

The Default JNDI Connection Pool maxsize is -No Maximum Size

Here you can find the default values of JNDI pool.

http://docs.oracle.com/javase/jndi/tutorial/ldap/connect/config.html

In order to get Efficient performance You should use a third party pool for best performance and stability.

If you are using an application server, you may wish to use the built-in pool (typically a connection is obtaining using JNDI). If you can't or don't wish to use your application server's built-in connection pool, Hibernate supports several other connection pools such as

  • c3p0

  • Apache DBCP

  • Proxool

http://www.informit.com/articles/article.aspx?p=353736&seqNum=4




回答3:


I found no documentation about Hibernate default values for connection pool, so I looked in the source code and found (class DriverManagerConnectionProviderImpl in hibernate-core-4.3.8.Final):

hibernate.connection.initial_pool_size = 1;
hibernate.connection.min_pool_size = 1;
hibernate.connection.pool_size = 20;
hibernate.connection.pool_validation_interval = 30;
hibernate.connection.autocommit = false;


来源:https://stackoverflow.com/questions/15758647/hibernate-default-connection-pooling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!