<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How to use connection pooling in portlet?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=24787072" />
  <subtitle>How to use connection pooling in portlet?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=24787072</id>
  <updated>2026-04-05T21:38:55Z</updated>
  <dc:date>2026-04-05T21:38:55Z</dc:date>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24880149" />
    <author>
      <name>Priyanka Dhingra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24880149</id>
    <updated>2013-05-20T11:28:23Z</updated>
    <published>2013-05-20T11:28:23Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Thanks this is what I was looking for.&lt;br&gt;But there is a problem, Whenever I deploy my code the {my-portlet}/META-INF/context.xml is blank after deployment, with just the following code in it&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;context antiJARLocking="true" antiResourceLocking="true" /&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;becoz of which i get nullPointerexception because there is no entry.&lt;br&gt;&lt;br&gt;If I replace this file manually in the server, then it works fine.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Priyanka Dhingra</dc:creator>
    <dc:date>2013-05-20T11:28:23Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24830298" />
    <author>
      <name>Kan Zhang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24830298</id>
    <updated>2013-05-17T15:07:24Z</updated>
    <published>2013-05-17T15:07:24Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div class="quote-title"&gt;Priyanka Dhingra:&lt;/div&gt;&lt;blockquote&gt;Thanks for the link..&lt;br&gt;but it will be great if someone can share a solution that can do connection pooling using ext-spring.xml&lt;/blockquote&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Are you using the approach mentioned in here?: http://www.liferay.com/web/sten.martinez/blog/-/blogs/using-a-legacy-db-with-service-builder&lt;br&gt;&lt;br&gt;If yes, then you should have a jndi name for your "legacy db" in ext-spring.xml similar to this:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;bean id="trainingDataSourceTarget" class="com.liferay.portal.spring.jndi.JndiObjectFactoryBean" lazy-init="true"&amp;gt;
    &amp;lt;property name="jndiName"&amp;gt;
        &amp;lt;value&amp;gt;jdbc/legacyDB&amp;lt;/value&amp;gt;
    &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;And in ${your.portlet.name}/docroot/META-INF/context.xml, you can define your jndiName. When you define your jndi name you will be configuring your connection pool:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;context antijarlocking="true" antiresourcelocking="true"&amp;gt;
    &amp;lt;resource name="jdbc/legacyDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="" password="" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://servername/databasename;domain=domainname" /&amp;gt;
&amp;lt;/context&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Don't forget, in your ${your.portlet.name}/docroot/WEB-INF/web.xml, you need to reference your jndiName:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
&amp;lt;resource-ref&amp;gt;
    &amp;lt;res-ref-name&amp;gt;jdbc/legacyDB&amp;lt;/res-ref-name&amp;gt;
    &amp;lt;res-type&amp;gt;javax.sql.DataSource&amp;lt;/res-type&amp;gt;
    &amp;lt;res-auth&amp;gt;Container&amp;lt;/res-auth&amp;gt;
&amp;lt;/resource-ref&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Kan Zhang</dc:creator>
    <dc:date>2013-05-17T15:07:24Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24821028" />
    <author>
      <name>Priyanka Dhingra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24821028</id>
    <updated>2013-05-17T10:17:33Z</updated>
    <published>2013-05-17T10:17:33Z</published>
    <summary type="html">Thanks for the link..&lt;br /&gt;but it will be great if someone can share a solution that can do connection pooling using ext-spring.xml</summary>
    <dc:creator>Priyanka Dhingra</dc:creator>
    <dc:date>2013-05-17T10:17:33Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24820273" />
    <author>
      <name>Jitendra Rajput</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24820273</id>
    <updated>2013-05-17T09:27:43Z</updated>
    <published>2013-05-17T09:27:43Z</published>
    <summary type="html">See if this &lt;a href="http://www.liferay.com/community/forums/-/message_boards/message/3332019"&gt;thread &lt;/a&gt;can help you ..!!</summary>
    <dc:creator>Jitendra Rajput</dc:creator>
    <dc:date>2013-05-17T09:27:43Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24818950" />
    <author>
      <name>Priyanka Dhingra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24818950</id>
    <updated>2013-05-17T09:07:28Z</updated>
    <published>2013-05-17T09:07:28Z</published>
    <summary type="html">I have a requirement where my portlet uses a different database and liferay tables are ata different database. So, I configured the database for my portlet by adding ext-spring.xml and then putting the data-source name in my service builder..&lt;br /&gt;&lt;br /&gt;Now I have to implement connection pooling for the database referred by the portlet. So, What should be done?</summary>
    <dc:creator>Priyanka Dhingra</dc:creator>
    <dc:date>2013-05-17T09:07:28Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24814074" />
    <author>
      <name>Jitendra Rajput</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24814074</id>
    <updated>2013-05-17T06:39:56Z</updated>
    <published>2013-05-17T06:39:56Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Liferay by default comes with c3po as default provider . But you can change it to DBCP or other check below properties in portal-ext. &lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt; #
    # Liferay can use C3PO, DBCP, or Tomcat for connection pooling. See
    # com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean for the actual
    # implementation. It is important to understand the strengths and weaknesses
    # of each provider so that you can choose the best one that fits your
    # deployment scenario. Provider specific properties can also be passed along
    # directly to the provider. For example, the property
    # "jdbc.default.acquireIncrement" is read by C3PO, and the property
    # "jdbc.default.maxActive" is read by DBCP.
    #
    # The default provider is C3PO.
    #

    jdbc.default.liferay.pool.provider=c3po
    #jdbc.default.liferay.pool.provider=dbcp
    #jdbc.default.liferay.pool.provider=tomcat&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Default pool size and other details you can get it from below properties&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
 #
    # The following properties will be read by C3PO if Liferay is configured to
    # use C3PO in the property "jdbc.default.liferay.pool.provider". See
    # http://www.mchange.com/projects/c3p0/index.html#configuration for a list
    # of additional fields used by C3PO for configuring database connections.
    #
    jdbc.default.acquireIncrement=5
    jdbc.default.acquireRetryAttempts=3
    jdbc.default.acquireRetryDelay=1000
    jdbc.default.connectionCustomizerClassName=com.liferay.portal.dao.jdbc.pool.c3p0.PortalConnectionCustomizer
    jdbc.default.idleConnectionTestPeriod=60
    jdbc.default.maxIdleTime=3600
    jdbc.default.maxPoolSize=100
    jdbc.default.minPoolSize=10
    jdbc.default.numHelperThreads=10
    #jdbc.default.transactionIsolation=1
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote&gt;Note : This is for entire portal not specific to any portlet&lt;/blockquote&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Jitendra Rajput</dc:creator>
    <dc:date>2013-05-17T06:39:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24812209" />
    <author>
      <name>Priyanka Dhingra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24812209</id>
    <updated>2013-05-17T04:52:23Z</updated>
    <published>2013-05-17T04:52:23Z</published>
    <summary type="html">How can we then increase or decrease the pool size?&lt;br /&gt;or any other modifications, if required?</summary>
    <dc:creator>Priyanka Dhingra</dc:creator>
    <dc:date>2013-05-17T04:52:23Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24801837" />
    <author>
      <name>Mika Koivisto</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24801837</id>
    <updated>2013-05-16T18:34:50Z</updated>
    <published>2013-05-16T18:34:50Z</published>
    <summary type="html">By default it uses Liferay&amp;#39;s connection pool. You don&amp;#39;t need to do anything special for that to work.</summary>
    <dc:creator>Mika Koivisto</dc:creator>
    <dc:date>2013-05-16T18:34:50Z</dc:date>
  </entry>
  <entry>
    <title>How to use connection pooling in portlet?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24787071" />
    <author>
      <name>Priyanka Dhingra</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=24787071</id>
    <updated>2013-05-16T10:30:54Z</updated>
    <published>2013-05-16T10:30:54Z</published>
    <summary type="html">How does liferay service builder supports connection pooling?&lt;br /&gt;If it does not, How can we define for the custom portlet.</summary>
    <dc:creator>Priyanka Dhingra</dc:creator>
    <dc:date>2013-05-16T10:30:54Z</dc:date>
  </entry>
</feed>
