hibernate default connection pooling
Asked Answered
O

3

19

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?

Outbreed answered 2/4, 2013 at 7:38 Comment(0)
C
10

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.

Crescendo answered 2/4, 2013 at 13:36 Comment(1)
Could you please share the source of default size of hibernate.connection.pool_size=1 ?, as you said in above link.Skaggs
C
6

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

Coryza answered 2/4, 2013 at 8:39 Comment(2)
This I know, my question is what is the default behavior? configuring nothing regarding the connection pooling.Outbreed
This does not answer the question.Tirpitz
U
6

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-5.2.0.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;
Uncompromising answered 16/3, 2018 at 17:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.