Adi Baron
Adi Baron

Reputation: 576

hibernate default connection pooling

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?

Upvotes: 20

Views: 54788

Answers (3)

Vjncenzo
Vjncenzo

Reputation: 73

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;

Upvotes: 7

Jordan Robinson
Jordan Robinson

Reputation: 865

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.

Upvotes: 10

Suresh Atta
Suresh Atta

Reputation: 121998

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

Upvotes: 7

Related Questions