Reputation: 2179
I am using hibernate with c3p0 for connection management. In my hibernate configuration I have both connection.pool_size
and hibernate.c3p0.max_size
configured (with different numbers).
As per my knowledge when I am using c3p0, my default hibernate connection management will not be in use.
But I am not sure whether hibernate.c3p0.max_size
is the c3p0 replacement of connection.pool_size
of default hibernate pool size setting variable.
So, my query is - Can I remove connection.pool_size
from the configuration?
If I have both in my configuration file, will connection.pool_size
be completely ignored or will it be used for any other purpose ?
Upvotes: 2
Views: 1866
Reputation: 91
You should actually remove the hibernate.connection.pool_size
from your configurations as it's already being replaced by cp30's specific settings - refer to the doc
Hibernate's own connection pooling algorithm is however quite rudimentary. It is intended to help you get started and is not intended for use in a production system or even for performance testing. You should use a third party pool for best performance and stability. Just replace the hibernate.connection.pool_size property with connection pool specific settings. This will turn off Hibernate's internal pool. For example, you might >like to use C3P0.
reference - https://docs.jboss.org/hibernate/stable/core.old/reference/en/html/configuration-hibernatejdbc.html
Update
I have read that Hikari CP offers better performance than C3P0 and other DB connection pool tools, and Hikari is natively supported by spring boot, so you'll be just fine with the defaults. However, if you ever want to tweak the defaults to cater for your particular use case, you can do so.
https://github.com/brettwooldridge/HikariCP
For how to configure Hikari parameters in your application.properties, check : https://gist.github.com/rhamedy/b3cb936061cc03acdfe21358b86a5bc6
Upvotes: 0
Reputation: 144
Once you defined configuration for c3po with session factory. No need of hibernate default settings. You should remove it to avoid confusion.
Your session factory configuration looks like :
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:ABCXYZ</property>
<property name="hibernate.connection.username">myuser</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">SCHEMA_A</property>
<property name="show_sql">true</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<mapping class="com.ABCXYZ.user.DBUser"></mapping>
</session-factory>
</hibernate-configuration>
Better you remove that connection.pool_size to make configuration settings clear to understand.
Upvotes: 3