Liferay JDBC connection Pool


Liferay JDBC Connection Pool

Liferay JDBC connection Pool tutorial will help you on choosing what connection pool mechanism is best for you. Out of the box, it  supports  C3PO, DBCP and  Tomcat JDBC for connection pooling and by default it uses C3P0.

What is the recommended connection pool for Liferay?

Most of the applications uses Liferay  with tomcat bundle. In this, personally I prefer Tomcat JDBC Connection pool which best and give good performance than C3P0 and DBCP. The reasons are:

  • C3P0- is good option but still there are some issue in connection pool.
  • DBCP is dead and community is  no longer supports

Personally I validated with C3P0 and Tomcat JDBC Connection and Tomcat JDBC given good performance over C3P0 and no connections time outs.

How to set Connection Provider in Liferay:

We can change connection pool provider details in portal-ext properties with below property:

jdbc.default.liferay.pool.provider=c3po
dbc.default.liferay.pool.provider=dbcp
jdbc.default.liferay.pool.provider=tomcat

Tomcat JDBC Pool Settings:

Portal Ext Properties:

jdbc.default.liferay.pool.provider=tomcat
jdbc.default.url=jdbc\:mysql\://loclhost:3306/liferay?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false&
autoReconnect=true&failOverReadOnly=false&maxReconnects=10
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.username=test
jdbc.default.password=root

JNDI Configuration:

    1. <Resource name="jdbc/TestDB"
                auth="Container"
                type="javax.sql.DataSource"
                factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                testWhileIdle="true"
                testOnBorrow="true"
                testOnReturn="false"
                validationQuery="SELECT 1"
                validationInterval="30000"
                timeBetweenEvictionRunsMillis="30000"
                maxActive="100"
                minIdle="10"
                maxWait="10000"
                initialSize="10"
                removeAbandonedTimeout="60"
                removeAbandoned="true"
                logAbandoned="true"
                minEvictableIdleTimeMillis="30000"
                jmxEnabled="true"
                jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
                  org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
                username="root"
                password="password"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost:3306/mysql"/>

Liferay C3PO Connection Pool Settings:

Portal ext properties:

jdbc.default.url=jdbc\:mysql\://loclhost:3306/liferay?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false&
autoReconnect=true&failOverReadOnly=false&maxReconnects=10
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.username=test
jdbc.default.password=root
jdbc.default.acquireIncrement=1
jdbc.default.acquireRetryAttempts=3
jdbc.default.acquireRetryDelay=1000
jdbc.default.idleConnectionTestPeriod=10
jdbc.default.maxIdleTime=3600
jdbc.default.maxPoolSize=100
jdbc.default.minPoolSize=10
jdbc.default.numHelperThreads=10

 

C3P0 JNDI Settings:

<Resource
 name="jdbc/LiferayPool"
 auth="Container"
 type="com.mchange.v2.c3p0.ComboPooledDataSource"
 factory="org.apache.naming.factory.BeanFactory"
 driverClass="com.mysql.jdbc.Driver"
 jdbcUrl="jdbc:mysql://localhost:3306/liferay?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false"
 user="lportal"
 password="test"
 minPoolSize="10"
 maxPoolSize="20"
 maxIdleTime="600"
 preferredTestQuery="select 1 from dual"
 idleConnectionTestPeriod="180"
 numHelperThreads="5"
 maxStatementsPerConnection="100"
 />

 

Comments are closed.