<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Use of Connection Pool</title><link>https://answers.axonivy.com/questions/1677/use-of-connection-pool</link><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Is it possible to use the connection pool from ivy in a Java class?&lt;/p&gt;
&lt;p&gt;I currently reading the database configuration with :
&lt;code&gt;
Ivy.wfCase().getApplication().findExternalDatabaseConfiguration("myDB")
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and open the configuration with:
&lt;code&gt;
ch.ivyteam.db.jdbc.DatabaseUtil.openConnection(dbConf)
ch.ivyteam.db.jdbc.DatabaseUtil.DatabaseUtil.closeConnection(conn);
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;With this approach it doesn't use the pooled connections like in an ivy database step.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1677/use-of-connection-pool" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 14 Mar 2016 13:55:14 -0400</lastBuildDate><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/1677/use-of-connection-pool/1682</link><description>&lt;p&gt;Hi &lt;/p&gt;
&lt;p&gt;You can use the following &lt;strong&gt;NON Public&lt;/strong&gt; API:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;IExternalDatabaseApplicationContext applicationDbContext =  (IExternalDatabaseApplicationContext)Ivy.wfCase().getApplication().getAdapter(IExternalDatabaseApplicationContext.class);
IExternalDatabase database = applicationDbContext.getExternalDatabase(externalDatabaseConfiguration);
Connection connection database.getConnection(); // get connection from pool
try
{
  ....
}
finally
{
  connection.close();  // give back connection to pool
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that this is an &lt;strong&gt;INTERNAL&lt;/strong&gt; API. Therefore, it can change without further notice from version to version.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Mon, 14 Mar 2016 13:55:14 -0400</pubDate><guid>https://answers.axonivy.com/questions/1677/use-of-connection-pool/1682</guid></item></channel></rss>