Hibernate4.3.8.final when configuring C3P0, error

Source: Internet
Author: User
Tags connection pooling jboss

Initial sessionfactory creation failed.org.hibernate.service.spi.ServiceException: Unable to Create requested service [Org.hibernate.engine.jdbc.connections.spi.ConnectionProvider]
The configuration in the configuration file is such that,<!--c3p0 connection Pool Settings--<!--use the C3P0 connection pool to configure the vendor that the connection pool provides--<property name= "Connection.provider_class" >org.hibernate.connection.c3p0connectionprovider</property ><!--the minimum number of database connections available in the connection pool--<property name= "C3p0.min_size" >5</property><!--The maximum number of all database connections in the connection pool--<property name= "C3p0.max_size" >20</property><!--set the expiration time of the database connection, in seconds,If a database connection in the connection pool is idle for more than the timeout time, it is purged from the connection pool and<property name= "C3p0.timeout" >120</property><!--check for idle connections in all connection pools in seconds every 3,000 seconds--<property name= "C3p0.idle_test_period" >3000</property>
Comment out this line and the error is gone.<property name= "Connection.provider_class" >org.hibernate.connection.c3p0connectionprovider</ Property>

View Hibernate4.3.8 's Manual, as stated:

not Intended for use with 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 would turn off Hibernate ' s internal pool. For example, you might like to use C3P0.

C3P0 is a open source JDBC connection pool distributed along with Hibernate in The lib  directory. Hibernate would use Its org.hibernate.connection.c3p0connectionprovider  for Connection Pooling If you sethibernate.properties  and the Hibernate web site for more information.

Hibernate.connection.driver_class = Org.postgresql.Driverhibernate.connection.url = jdbc:postgresql://localhost/ Mydatabasehibernate.connection.username = Myuserhibernate.connection.password = secrethibernate.c3p0.min_size= 5hibernate.c3p0.max_size=20hibernate.c3p0.timeout=1800hibernate.c3p0.max_statements=50hibernate.dialect = Org.hibernate.dialect.PostgreSQL82Dialect

This means that you just need to

hibernate.connection.pool_size replaced by

Hibernate.c3p0.min_size=5hibernate.c3p0.max_size=20hibernate.c3p0.timeout=1800hibernate.c3p0.max_statements=50

These properties are OK, not to mention the configurationConnection.provider_classThis property.

From for notes (Wiz)

Hibernate4.3.8.final when configuring C3P0, error

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.