Este contenido no está disponible en el idioma seleccionado.

2.3. Connection Pooling


2.3.1. About Connection Pooling

Hibernate includes a rudimentary internal connection pooling algorithm for development and testing purposes. Use a third party pool for improved performance and stability.
To set a third party connection pool, replace the hibernate.connection.pool_size property with the appropriate settings for your selected connection pool. Setting a new value automatically disabled Hibernate's internal connection pool.

2.3.2. C3P0 Connection Pool

C3P0 is an open source JDBC connection pool that is distributed with Hibernate. C3P0 is available in the lib/ directory. Hibernate uses org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider for connection pooling if the hibernate.c3p0 connection properties are set.
The following table contains hibernate.c3p0 connection properties to set to use the c3p0 connection pool in Hibernate:
Expand
Table 2.7. Configuration Properties for the C3p0 Connection Pool
Property Details
hibernate.c3p0.min_size The minimum number of concurrent connections per connection identity.
hibernate.c3p0.max_size The maximum number of concurrent connections per connection identity.
hibernate.c3p0.timeout The period an idle connection is allowed to remain in the connection pool before it is closed and removed from the pool.
hibernate.c3p0.max_statements The maximum size of the statement cache.

2.3.3. Use JNDI to Obtain a Connection

To use Hibernate inside an application server, configure Hibernate to obtain connections from an application server (javax.sql.Datasource) that is registered in JNDI. Set more than one of the following properties to configure JNDI to obtain a connection:
Expand
Table 2.8. JNDI Properties
Property Name Description
hibernate.connection.datasource Datasource JNDI name (mandatory).
hibernate.jndi.url URL of the JNDI provider (optional).
hibernate.jndi.class Class of the JNDI InitialContextFactory (optional).
hibernate.connection.username Database user (optional).
hibernate.connection.password Database user's password (optional).

2.3.4. Other Connection Specific Configurations

Pass custom connection properties by appending the name of the new property to hibernate.connection. For example, to specify a charSet property, specify a new charSet connection property names hibernate.connection.charSet.
Pass custom plugin strategies to obtain JDBC connections by implementing the org.hibernate.service.jdbc.connections.spi.ConnectionProvider and by specifying a custom implementation with the hibernate.connection.provider_class property.
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat