When should I use hibernate.connection.provider_class
? I am a little confused between it and 'hibernate.connection.diver_class'.
provider_class might be useful for connection pool
is there any other purpose where we can use provider_class?
A connection pool is used to minimize the number of connections opened between application and database. It serves as a librarian, checking out connections to application code as needed.
C3p0 is an open-source JDBC connection pooling library, with support for caching and reuse of PreparedStatements. Hibernate provides support for Java applications to use c3p0 for connection pooling with additional configuration settings.
The Hibernate Connection Pool Size property establishes the number of connections that are permitted between the Model repository and the Model Repository Service database. The default value is 10. In deployments with many concurrent connections, you can increase the property to increase performance.
Likewise, the hibernate.properties file can contain the same settings: hibernate.c3p0.min_size=5 hibernate.c3p0.max_size=20 hibernate.c3p0.acquire_increment=5 hibernate.c3p0.timeout=1800. The min_size property specifies the minimum number of connections it should maintain at any given time.
Another use for connection provider is to uphold sessions over time, this is especially true with the combination of mysql + hibernate. If you don't have a properly configured connection provider that handles timeouts from mysql, you're likely to loose your connection to the database sooner or later if you have periods of inactivity.
The driver class is what it sais it is, what driver do you use to connect to your db. The connection provider class is class that can manage your connections for you and provide it to the session.
Have a look at: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html
The connection provider class is usually used if you want to use connection pooling. eg: hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider.
ConnectionProvider is what you use to customize your strategy for obtaining connections. As well as connection pooling, it can be used to implement multi-tenancy databases.
A brief run-thru:
http://literatejava.com/hibernate/multi-tenancy-architecture-with-hibernate/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With