<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_Create_an_External_Connection_Pool</id>
	<title>How to Create an External Connection Pool - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_Create_an_External_Connection_Pool"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_Create_an_External_Connection_Pool&amp;action=history"/>
	<updated>2026-04-06T15:13:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_to_Create_an_External_Connection_Pool&amp;diff=2748&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;{{(!)| The use of external connection pools is available from '''3.0MP32'''}}  == Introduction ==  Openbravo uses connection pools to reuse existing connections/prepared state...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_Create_an_External_Connection_Pool&amp;diff=2748&amp;oldid=prev"/>
		<updated>2021-12-16T02:17:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{(!)| The use of external connection pools is available from &amp;#039;&amp;#039;&amp;#039;3.0MP32&amp;#039;&amp;#039;&amp;#039;}}  == Introduction ==  Openbravo uses connection pools to reuse existing connections/prepared state...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{(!)| The use of external connection pools is available from '''3.0MP32'''}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
* Hibernate default connection pool for DAL-related queries&lt;br /&gt;
* [http://commons.apache.org/proper/commons-dbcp/ Apache DBCP] for the connections provided by the ConnectionProviderImpl.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== ExternalConnectionPool abstract class ==&lt;br /&gt;
&lt;br /&gt;
In order to implement an external connection pool, developers must subclass the ExternalConnectionPool abstract class. This class has three methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;/**&lt;br /&gt;
   * &lt;br /&gt;
   * @param externalConnectionPoolClassName&lt;br /&gt;
   *          The full class name of the external connection pool&lt;br /&gt;
   * @return An instance of the external connection pool&lt;br /&gt;
   */&lt;br /&gt;
public final synchronized static ExternalConnectionPool getInstance(&lt;br /&gt;
      String externalConnectionPoolClassName) throws InstantiationException,&lt;br /&gt;
      IllegalAccessException, ClassNotFoundException;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 Openbravo.properties.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;/**&lt;br /&gt;
   * @return A Connection from the external connection pool&lt;br /&gt;
   */&lt;br /&gt;
public abstract Connection getConnection()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;/**&lt;br /&gt;
   * If the external connection pool supports interceptors this method should be overwritten&lt;br /&gt;
   * &lt;br /&gt;
   * @param interceptors&lt;br /&gt;
   *          List of PoolInterceptorProvider comprised of all the interceptors injected with Weld&lt;br /&gt;
   */&lt;br /&gt;
public void loadInterceptors(List&amp;lt;PoolInterceptorProvider&amp;gt; interceptors)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Design Considerations ==&lt;br /&gt;
&lt;br /&gt;
* Include a configuration file so that users can customize the external connection pool to meet their needs.&lt;br /&gt;
* If the pool needs to execute some initialization code, place it in the getConnection method and make sure that is only executed the first time that method is invoked.&lt;br /&gt;
* For all connection returned by the pool:&lt;br /&gt;
** SessionInfo.setDBSessionInfo(Connection conn, String rdbms) must be executed&lt;br /&gt;
** The sql query included in the '''bbdd.sessionConfig''' property must be executed using that connection.&lt;br /&gt;
* Take into account that these two operations must be executed on the returned connection only when the connection is actually created, not every time it is returned from the pool.&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>