Search code examples
javahibernateconnection-poolingc3p0

if c3p0 is configured, will connection.pool_size be ignored


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 ?


Solution

  • 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.