Author: tolusha
Date: 2011-10-07 10:20:26 -0400 (Fri, 07 Oct 2011)
New Revision: 5032
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java
Log:
EXOJCR-1579: RDBMS reindexing only if db2 version >= 9.7.2
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java 2011-10-07
13:02:09 UTC (rev 5031)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java 2011-10-07
14:20:26 UTC (rev 5032)
@@ -41,6 +41,8 @@
public class DB2ConnectionFactory extends GenericCQConnectionFactory
{
+ private Boolean isReindexingSupport;
+
/**
* DB2ConnectionFactory constructor.
*
@@ -140,54 +142,59 @@
@Override
public boolean isReindexingSupport()
{
- Connection con = null;
- try
+ if (isReindexingSupport == null)
{
- con = getJdbcConnection();
- DatabaseMetaData metaData = con.getMetaData();
- if (metaData.getDatabaseMajorVersion() > 9)
+ Connection con = null;
+ try
{
- return true;
+ con = getJdbcConnection();
+ DatabaseMetaData metaData = con.getMetaData();
+ if (metaData.getDatabaseMajorVersion() > 9)
+ {
+ isReindexingSupport = true;
+ }
+ else if (metaData.getDatabaseMajorVersion() == 9 &&
metaData.getDatabaseMinorVersion() > 7)
+ {
+ isReindexingSupport = true;
+ }
+ else if (metaData.getDatabaseMajorVersion() == 9 &&
metaData.getDatabaseMinorVersion() == 7)
+ {
+ // returned string like 'SQL09074'
+ char maintenanceVersion =
+
metaData.getDatabaseProductVersion().charAt(metaData.getDatabaseProductVersion().length()
- 1);
+ isReindexingSupport = new Integer(maintenanceVersion) >= 2;
+ }
+ else
+ {
+ isReindexingSupport = false;
+ }
}
- else if (metaData.getDatabaseMajorVersion() == 9 &&
metaData.getDatabaseMinorVersion() > 7)
+ catch (Exception e)
{
- return true;
+ isReindexingSupport = false;
+ log.error("Error checking product version.", e);
}
- else if (metaData.getDatabaseMajorVersion() == 9 &&
metaData.getDatabaseMinorVersion() == 7)
+ finally
{
- // returned string like 'SQL09074'
- char maintenanceVersion =
-
metaData.getDatabaseProductVersion().charAt(metaData.getDatabaseProductVersion().length()
- 1);
- if (new Integer(maintenanceVersion) >= 2)
+ if (con != null)
{
- return true;
+ try
+ {
+ con.close();
+ }
+ catch (SQLException e)
+ {
+ // ignore me
+ }
}
}
- }
- catch (SQLException e)
- {
- log.error("Error checking product version.", e);
- }
- catch (RepositoryException e)
- {
- log.error("Error checking product version.", e);
- }
- finally
- {
- if (con != null)
+
+ if (!isReindexingSupport)
{
- try
- {
- con.close();
- }
- catch (SQLException e)
- {
- // ignore me
- }
+ log.debug("The version of DB2 is prior to 9.7.2, so the old indexing
mechanism will be used");
}
}
-
- log.debug("The version of DB2 is prior to 9.7.2, so the old indexing mechanism
will be used");
- return false;
- }
+
+ return isReindexingSupport;
+ }
}
Show replies by date