1. Configuration of Hibernate3 c3p0 connection pool
Configure the following information in Hibernate.cfg.xml:
<!--1. Database Connection Configuration - < Propertyname= "Hibernate.connection.driver_class">Com.mysql.jdbc.Driver</ Property> < Propertyname= "Hibernate.connection.url">Jdbc:mysql:///hib_demo</ Property> < Propertyname= "Hibernate.connection.username">Root</ Property> < Propertyname= "Hibernate.connection.password">Root</ Property> <!--Database method configuration, Hibernate generates SQL that conforms to the current database syntax in different dialects when it is run - < Propertyname= "Hibernate.dialect">Org.hibernate.dialect.MySQL5Dialect</ Property> <!--2. Other related configurations - <!--2.1 shows the SQL statement that hibernate executes at run time - < Propertyname= "Hibernate.show_sql">True</ Property> <!--2.2 Formatting SQL <property name= "Hibernate.format_sql" >true</property> - <!--2.3 Auto-build table - < Propertyname= "Hibernate.hbm2ddl.auto">Update</ Property> <!--Configuring session Creation: Threading to create session objects - < Propertyname= "Hibernate.current_session_context_class">Thread</ Property> <!--****************** "Connection pool Configuration" ****************** - <!--Configuring the connection-driven management class - < Propertyname= "Hibernate.connection.provider_class">Org.hibernate.connection.C3P0ConnectionProvider</ Property> <!--Configuring connection pool parameter information - < Propertyname= "Hibernate.c3p0.min_size">2</ Property> < Propertyname= "Hibernate.c3p0.max_size">4</ Property> < Propertyname= "Hibernate.c3p0.timeout">5000</ Property> < Propertyname= "Hibernate.c3p0.max_statements">10</ Property> < Propertyname= "Hibernate.c3p0.idle_test_period">30000</ Property> < Propertyname= "Hibernate.c3p0.acquire_increment">2</ Property>
2. Configuration of Hibernate4 c3p0 connection pool
Hibernate-c3p0-4.1.2.final.jar, to join, and Hibernate.connection.provider_class,hibernate3 and Hibernate4 are not the same
Configure the following information in Hibernate.cfg.xml:
<!--Configuring connection information for a database - < Propertyname= "Hibernate.dialect">Org.hibernate.dialect.MySQLMyISAMDialect</ Property> < Propertyname= "Hibernate.connection.driver_class">Com.mysql.jdbc.Driver</ Property> < Propertyname= "Hibernate.connection.url">Jdbc:mysql:///student</ Property> < Propertyname= "Hibernate.connection.username">Root</ Property> < Propertyname= "Hibernate.connection.password">1234</ Property> <!--Display Debugging Information - < Propertyname= "Show_sql">True</ Property> < Propertyname= "Format_sql">True</ Property> < Propertyname= "Hibernate.hbm2ddl.auto">Update</ Property> <!--Configuring the connection-driven management class - < Propertyname= "Hibernate.connection.provider_class">Org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</ Property> <!--Configuring connection pool parameter information - < Propertyname= "Hibernate.c3p0.min_size">2</ Property> < Propertyname= "Hibernate.c3p0.max_size">4</ Property> < Propertyname= "Hibernate.c3p0.timeout">5000</ Property> < Propertyname= "Hibernate.c3p0.max_statements">10</ Property> < Propertyname= "Hibernate.c3p0.idle_test_period">30000</ Property> < Propertyname= "Hibernate.c3p0.acquire_increment">2</ Property>
14. Hibernate configuration of the C3P0 connection pool