14. Hibernate configuration of the C3P0 connection pool

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.