Posts

Showing posts with the label connection

Database connection pool C3po configuration in liferay

In Liferay, default connection pool is c3p0 configured using portal-ext.properties. Liferay Portal also supports the database connection pool configuration through the Application Server. Liferay can access the Application Server level data source using JNDI. It is recommended to use the JNDI-based database connection pool configuration. Add the following property in the portal-ext.properties. jdbc.default.jndi.name=jdbc/LiferayPool Open the server.xml in the <liferay-home>/tomcat/conf folder Locate the Resource tag and add the following properties. <Resource auth="Container" description="Portal DB Connection" driverClass="com.mysql.jdbc.Driver" maxPoolSize="75" minPoolSize="10" acquireIncrement="5" name="jdbc/LiferayPool" user="<MySQL Database User Name>" password="<MySQL Password>" factory="org.apache.naming.factory.BeanFactory" ...

How liferay is identifying the database configuration

In liferay we configure the database configuration properties in the portal-ext.properties. So when we restart the server or during server startup , we can see the log as  Determine dialect for MYSQL5 or if it is orcale  Determine dialect for oracle 11g . so how liferay is identifying? In Liferay have a look in to the  DialectDetector class and the method  getDialect(DataSource dataSource) . Look into the following code in the method. Connection connection = dataSource.getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); String dbName = databaseMetaData.getDatabaseProductName(); int dbMajorVersion = databaseMetaData.getDatabaseMajorVersion(); dialectKey = dbName.concat(StringPool.COLON).concat( String.valueOf(dbMajorVersion)); dialect = _dialects.get(dialectKey); if (_log.isInfoEnabled()) { _log.info("Determine dialect for " + dbName + " " + dbMajorVersion); } else if (dbName.startsWith("Oracle") &...