View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Modules:Tomcat JDBC Connection Pool

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

Contents

Introduction

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.

Advantages of using JDBC Connection Pool

Adding Interceptors

Adding a custom interceptor is very easy. You just have this into consideration:

package org.openbravo.tomcatjdbcconnectionpool;
 
import java.lang.reflect.Method;
 
import javax.enterprise.context.ApplicationScoped;
 
import org.apache.tomcat.jdbc.pool.ConnectionPool;
import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
import org.apache.tomcat.jdbc.pool.PooledConnection;
import org.openbravo.database.PoolInterceptorProvider;
 
@ApplicationScoped
public class TestInterceptor extends JdbcInterceptor implements PoolInterceptorProvider {
 
  public void reset(ConnectionPool parent, PooledConnection con) {
    // Actions after a connection has been borrowed from the pool
  }
 
  // Gets invoked each time an operation on Connection is invoked.
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    // Actions before the method invocation
    Object object = super.invoke(proxy, method, args);
    // Actions before the method invocation
    return object;
  }
 
  @Override
  // Return the full name of the interceptor class
  public String getPoolInterceptorsClassName() {
    String fullClassName = this.getClass().getName();
    return fullClassName + ";";
  }
}

Inclusion in Openbravo.properties

Openbravo will not start using the external connection pool until the module has been installed and the following line has been added to Openbravo.properties:

db.externalPoolClassName=org.openbravo.tomcatjdbcconnectionpool.JdbcExternalConnectionPool

Pool Configuration

The Tomcat JDBC Connection Pool can be configured to meet your environment needs. These are some of the parameters that can be configured:

The full list of configurable properties can be found here. This link provides information about about how to configure these properties for high concurrent environments.

To configure the pool properties, the modules/org.openbravo.tomcatjdbcconnectionpool/config/connectionPool.properties.template file has to be copied to modules/org.openbravo.tomcatjdbcconnectionpool/config/connectionPool.properties, and then the properties of that file must be assigned so that the pool behaves according to the environment needs.

Retrieved from "http://wiki.openbravo.com/wiki/Modules:Tomcat_JDBC_Connection_Pool"

This page has been accessed 790 times. This page was last modified on 17 February 2014, at 10:58. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.