View source | Discuss this page | Page history | Printable version   

How to Create an External Connection Pool

Bulbgraph.png   The use of external connection pools is available from 3.0MP32


Openbravo uses connection pools to reuse existing connections/prepared statements, avoiding the cost of initiating a connection, parsing SQL etc. By default Openbravo uses two different connection pools:

From 3.0MP32 it is possible to specify an external connection provider to replace these two connection pools. Openbravo provides a free commercial module that implements the Tomcat JDBC Connection Pool, but it is possible for developers to publish a module implement their own connection pool.

ExternalConnectionPool abstract class

In order to implement an external connection pool, developers must subclass the ExternalConnectionPool abstract class. This class has three methods:

   * @param externalConnectionPoolClassName
   *          The full class name of the external connection pool
   * @return An instance of the external connection pool
public final synchronized static ExternalConnectionPool getInstance(
      String externalConnectionPoolClassName) throws InstantiationException,
      IllegalAccessException, ClassNotFoundException;

The getInstance method is in charge of instantiating the external connection pool. The name of the class that implements the connection pool is passed as a parameter, its value is taken from the db.externalPoolClassName property of

   * @return A Connection from the external connection pool
public abstract Connection getConnection()

This is the main method that should be overwritten by all external connection providers. It takes no arguments, and it should return a connection that has been borrowed from the pool.

   * If the external connection pool supports interceptors this method should be overwritten
   * @param interceptors
   *          List of PoolInterceptorProvider comprised of all the interceptors injected with Weld
public void loadInterceptors(List<PoolInterceptorProvider> interceptors)

This method should be overwritten if the connection pool supports interceptors and allows custom interceptors to be instantiated using dependency injection. A list of PoolInterceptorProvider will be passed as an arguments, containing the full class name of the interceptors.

Design Considerations

Retrieved from ""

This page has been accessed 5,752 times. This page was last modified on 14 February 2014, at 15:40. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.