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") && (dbMajorVersion >= 10)) {
dialect = new Oracle10gDialect();
}



Based on these calculations liferay dects the DB Configuration.

Comments

Popular posts from this blog

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate

Executing the BackGround Task