<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Using DB-Connection from PIs</title><link>https://answers.axonivy.com/questions/314/using-db-connection-from-pis</link><description>Is it possible to access the DB connection from a PI using &lt;br/&gt;
&lt;br/&gt;
ivy.getProcessEngineHook().getDbConnection(dbName);&lt;br/&gt;
&lt;br/&gt;
as well as for returning (instead of closing):&lt;br/&gt;
&lt;br/&gt;
ivy.getProcessEngineHook().returnDbConnection(dbName, connection); ?&lt;br/&gt;
&lt;br/&gt;
Is this way of accessing the underlying datasource (for SELECT queries inside a PI) the correct one or does this interfere with other queries from Ivy DB process elements running at the same time?&lt;br/&gt;
</description><atom:link href="https://answers.axonivy.com/questions/314/using-db-connection-from-pis" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 13 Jan 2010 06:06:03 -0500</lastBuildDate><item><title>Answer by SupportIvyTeam</title><link>https://answers.axonivy.com/questions/314/using-db-connection-from-pis/315</link><description>&lt;p&gt;This is the right way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import  java.sql.Connection;   
// connect to the database
Connection dbconnection = ivy.getProcessEngineHook().getDbConnection(dbName);
try
{
  // execute sql queries
} finally {
  // close the connection
  dbconnection.close();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Of course, it is possible that at the same time other queries are executed, but this should not be a problem.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SupportIvyTeam</dc:creator><pubDate>Wed, 13 Jan 2010 06:06:03 -0500</pubDate><guid>https://answers.axonivy.com/questions/314/using-db-connection-from-pis/315</guid></item></channel></rss>