hibernate default connection pooling

后端 未结 3 1476
感情败类
感情败类 2020-12-18 20:48

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*? Is

相关标签:
3条回答
  • 2020-12-18 21:22

    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.

    0 讨论(0)
  • 2020-12-18 21:23

    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

    0 讨论(0)
  • 2020-12-18 21:29

    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;
    
    0 讨论(0)
提交回复
热议问题