Correct way to implement HTTP Connection Pooling

Beware of how HTTP Client pools work, it may be improving performance during a short period of time. Check the analysis below: From PoolingHttpClientConnectionManager javadocs The handling of stale connections was changed in version 4.4. Previously, the code would check every connection by default before re-using it. The code now only checks the connection if … Read more

Correct way to keep pooled connections alive (or time them out and get fresh ones) during longer inactivity for MySQL, Grails 2 app

The easiest is to configure the connection pool to specify the query to be run to test the connection before it is passed to the application: validationQuery=”select 1 as dbcp_connection_test” testOnBorrow=true This same “connection validation” query can be run on other events. I’m not sure of the defaults for these: testOnReturn=true testWhileIdle=true There are also … Read more

HikariCP: What database level timeouts should be considered to set maxLifetime for Oracle 11g

Short answer: none (by default). For the record (to include details here in case the link changes), we’re talking about property maxLifetime of HikariCP: This property controls the maximum lifetime of a connection in the pool. An in-use connection will never be retired, only when it is closed will it then be removed. We strongly … Read more

hibernate connection pool

<!DOCTYPE hibernate-configuration PUBLIC “-//Hibernate/Hibernate Configuration DTD 3.0//EN” “http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”> <hibernate-configuration> <session-factory> <!– datasource config –> <property name=”connection.url”>jdbc:mysql://localhost:3306/db?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true</property> <property name=”hibernate.dialect”>org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name=”connection.driver_class”>com.mysql.jdbc.Driver</property> <property name=”connection.username”>user</property> <property name=”connection.password”>pass</property> <!– c3p0 config http://www.hibernate.org/214.html –> <property name=”connection.provider_class”>org.hibernate.connection.C3P0ConnectionProvider</property> <property name=”hibernate.c3p0.acquire_increment”>1</property> <property name=”hibernate.c3p0.idle_test_period”>60</property> <property name=”hibernate.c3p0.min_size”>1</property> <property name=”hibernate.c3p0.max_size”>2</property> <property name=”hibernate.c3p0.max_statements”>50</property> <property name=”hibernate.c3p0.timeout”>0</property> <property name=”hibernate.c3p0.acquireRetryAttempts”>1</property> <property name=”hibernate.c3p0.acquireRetryDelay”>250</property> <property name=”hibernate.show_sql”>true</property> <property name=”hibernate.use_sql_comments”>true</property> <property name=”hibernate.transaction.factory_class”>org.hibernate.transaction.JDBCTransactionFactory</property> <property name=”hibernate.current_session_context_class”>thread</property> … Read more

Is there any way to have the JBoss connection pool reconnect to Oracle when connections go bad?

Whilst you can use the old “select 1 from dual” trick, the downside with this is that it issues an extra query each and every time you borrow a connection from the pool. For high volumes, this is wasteful. JBoss provides a special connection validator which should be used for Oracle: <valid-connection-checker-class-name> org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker </valid-connection-checker-class-name> This … Read more