Author: tolusha
Date: 2010-05-26 10:31:13 -0400 (Wed, 26 May 2010)
New Revision: 2438
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-754: close PreparedStatement on connection close
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-05-26
13:39:19 UTC (rev 2437)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-05-26
14:31:13 UTC (rev 2438)
@@ -121,6 +121,68 @@
protected final WriteValueHelper writeValueHelper = new WriteValueHelper();
+ // All statements should be closed in cloaseStatements() method.
+
+ protected PreparedStatement findItemById;
+
+ protected PreparedStatement findItemByPath;
+
+ protected PreparedStatement findItemByName;
+
+ protected PreparedStatement findChildPropertyByPath;
+
+ protected PreparedStatement findPropertyByName;
+
+ protected PreparedStatement findDescendantNodes;
+
+ protected PreparedStatement findDescendantProperties;
+
+ protected PreparedStatement findReferences;
+
+ protected PreparedStatement findValuesByPropertyId;
+
+ protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+
+ protected PreparedStatement findValuesDataByPropertyId;
+
+ protected PreparedStatement findValueByPropertyIdOrderNumber;
+
+ protected PreparedStatement findNodesByParentId;
+
+ protected PreparedStatement findNodesCountByParentId;
+
+ protected PreparedStatement findPropertiesByParentId;
+
+ protected PreparedStatement insertItem;
+
+ protected PreparedStatement insertNode;
+
+ protected PreparedStatement insertProperty;
+
+ protected PreparedStatement insertReference;
+
+ protected PreparedStatement insertValue;
+
+ protected PreparedStatement updateItem;
+
+ protected PreparedStatement updateItemPath;
+
+ protected PreparedStatement updateNode;
+
+ protected PreparedStatement updateProperty;
+
+ protected PreparedStatement deleteItem;
+
+ protected PreparedStatement deleteNode;
+
+ protected PreparedStatement deleteProperty;
+
+ protected PreparedStatement deleteReference;
+
+ protected PreparedStatement deleteValue;
+
+ protected PreparedStatement renameNode;
+
/**
* Read-only flag, if true the connection is marked as READ-ONLY.
*/
@@ -303,6 +365,8 @@
checkIfOpened();
try
{
+ closeStatements();
+
// If READ-ONLY status back it to READ-WRITE (we assume it was original state)
if (readOnly)
{
@@ -318,6 +382,164 @@
}
/**
+ * Close all statements.
+ *
+ * @throws SQLException
+ */
+ protected void closeStatements() throws SQLException
+ {
+ if (findItemById != null)
+ {
+ findItemById.close();
+ }
+
+ if (findItemByPath != null)
+ {
+ findItemByPath.close();
+ }
+
+ if (findItemByName != null)
+ {
+ findItemByName.close();
+ }
+
+ if (findChildPropertyByPath != null)
+ {
+ findChildPropertyByPath.close();
+ }
+
+ if (findPropertyByName != null)
+ {
+ findPropertyByName.close();
+ }
+
+ if (findDescendantNodes != null)
+ {
+ findDescendantNodes.close();
+ }
+
+ if (findDescendantProperties != null)
+ {
+ findDescendantProperties.close();
+ }
+
+ if (findReferences != null)
+ {
+ findReferences.close();
+ }
+
+ if (findValuesByPropertyId != null)
+ {
+ findValuesByPropertyId.close();
+ }
+
+ if (findValuesStorageDescriptorsByPropertyId != null)
+ {
+ findValuesStorageDescriptorsByPropertyId.close();
+ }
+
+ if (findValuesDataByPropertyId != null)
+ {
+ findValuesDataByPropertyId.close();
+ }
+
+ if (findValueByPropertyIdOrderNumber != null)
+ {
+ findValueByPropertyIdOrderNumber.close();
+ }
+
+ if (findNodesByParentId != null)
+ {
+ findNodesByParentId.close();
+ }
+
+ if (findNodesCountByParentId != null)
+ {
+ findNodesCountByParentId.close();
+ }
+
+ if (findPropertiesByParentId != null)
+ {
+ findPropertiesByParentId.close();
+ }
+
+ if (insertItem != null)
+ {
+ insertItem.close();
+ }
+
+ if (insertNode != null)
+ {
+ insertNode.close();
+ }
+
+ if (insertProperty != null)
+ {
+ insertProperty.close();
+ }
+
+ if (insertReference != null)
+ {
+ insertReference.close();
+ }
+
+ if (insertValue != null)
+ {
+ insertValue.close();
+ }
+
+ if (updateItem != null)
+ {
+ updateItem.close();
+ }
+
+ if (updateItemPath != null)
+ {
+ updateItemPath.close();
+ }
+
+ if (updateNode != null)
+ {
+ updateNode.close();
+ }
+
+ if (updateProperty != null)
+ {
+ updateProperty.close();
+ }
+
+ if (deleteItem != null)
+ {
+ deleteItem.close();
+ }
+
+ if (deleteNode != null)
+ {
+ deleteNode.close();
+ }
+
+ if (deleteProperty != null)
+ {
+ deleteProperty.close();
+ }
+
+ if (deleteReference != null)
+ {
+ deleteReference.close();
+ }
+
+ if (deleteValue != null)
+ {
+ deleteValue.close();
+ }
+
+ if (renameNode != null)
+ {
+ renameNode.close();
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public final void commit() throws IllegalStateException, RepositoryException
@@ -948,7 +1170,7 @@
{
return traverseQPathSQ(cpid);
}
-
+
/**
* The method <code>traverseQPath</code> implemented thanks to simple
queries. It allows
* to use Simple Queries instead of Complex Queries when complex queries are much
slower such
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2010-05-26
13:39:19 UTC (rev 2437)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2010-05-26
14:31:13 UTC (rev 2438)
@@ -31,7 +31,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@@ -51,66 +50,6 @@
public class MultiDbJDBCConnection extends JDBCStorageConnection
{
- protected PreparedStatement findItemById;
-
- protected PreparedStatement findItemByPath;
-
- protected PreparedStatement findItemByName;
-
- protected PreparedStatement findChildPropertyByPath;
-
- protected PreparedStatement findPropertyByName;
-
- protected PreparedStatement findDescendantNodes;
-
- protected PreparedStatement findDescendantProperties;
-
- protected PreparedStatement findReferences;
-
- protected PreparedStatement findValuesByPropertyId;
-
- protected PreparedStatement findValuesDataByPropertyId;
-
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
-
- protected PreparedStatement findValueByPropertyIdOrderNumber;
-
- protected PreparedStatement findNodesByParentId;
-
- protected PreparedStatement findNodesCountByParentId;
-
- protected PreparedStatement findPropertiesByParentId;
-
- protected PreparedStatement insertNode;
-
- protected PreparedStatement insertProperty;
-
- protected PreparedStatement insertReference;
-
- protected PreparedStatement insertValue;
-
- protected PreparedStatement updateItem;
-
- protected PreparedStatement updateItemPath;
-
- protected PreparedStatement updateNode;
-
- protected PreparedStatement updateProperty;
-
- protected PreparedStatement updateValue;
-
- protected PreparedStatement deleteItem;
-
- protected PreparedStatement deleteNode;
-
- protected PreparedStatement deleteProperty;
-
- protected PreparedStatement deleteReference;
-
- protected PreparedStatement deleteValue;
-
- protected PreparedStatement renameNode;
-
/**
* Multidatabase JDBC Connection constructor.
*
@@ -183,10 +122,11 @@
FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=?";
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA, STORAGE_DESC from
JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
+ "select DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? and
ORDER_NUM=?";
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
-
+
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + "
where I_CLASS=1 and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where
I_CLASS=2 and PARENT_ID=?" + " order by ID";
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2010-05-26
13:39:19 UTC (rev 2437)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2010-05-26
14:31:13 UTC (rev 2438)
@@ -30,7 +30,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@@ -49,68 +48,6 @@
public class SingleDbJDBCConnection extends JDBCStorageConnection
{
- protected PreparedStatement findItemById;
-
- protected PreparedStatement findItemByPath;
-
- protected PreparedStatement findItemByName;
-
- protected PreparedStatement findChildPropertyByPath;
-
- protected PreparedStatement findPropertyByName;
-
- protected PreparedStatement findDescendantNodes;
-
- protected PreparedStatement findDescendantProperties;
-
- protected PreparedStatement findReferences;
-
- protected PreparedStatement findValuesByPropertyId;
-
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
-
- protected PreparedStatement findValuesDataByPropertyId;
-
- protected PreparedStatement findValueByPropertyIdOrderNumber;
-
- protected PreparedStatement findNodesByParentId;
-
- protected PreparedStatement findNodesCountByParentId;
-
- protected PreparedStatement findPropertiesByParentId;
-
- protected PreparedStatement insertItem;
-
- protected PreparedStatement insertNode;
-
- protected PreparedStatement insertProperty;
-
- protected PreparedStatement insertReference;
-
- protected PreparedStatement insertValue;
-
- protected PreparedStatement updateItem;
-
- protected PreparedStatement updateItemPath;
-
- protected PreparedStatement updateNode;
-
- protected PreparedStatement updateProperty;
-
- protected PreparedStatement updateValue;
-
- protected PreparedStatement deleteItem;
-
- protected PreparedStatement deleteNode;
-
- protected PreparedStatement deleteProperty;
-
- protected PreparedStatement deleteReference;
-
- protected PreparedStatement deleteValue;
-
- protected PreparedStatement renameNode;
-
/**
* Singledatabase JDBC Connection constructor.
*
@@ -190,7 +127,8 @@
FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from
JCR_SVALUE where PROPERTY_ID=?";
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA, STORAGE_DESC from
JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
+ "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and
ORDER_NUM=?";
FIND_NODES_BY_PARENTID =
"select * from JCR_SITEM" + " where I_CLASS=1 and
CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-05-26
13:39:19 UTC (rev 2437)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-05-26
14:31:13 UTC (rev 2438)
@@ -41,6 +41,7 @@
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -91,6 +92,14 @@
*/
protected String FIND_ITEM_QPATH_BY_ID_CQ;
+ protected PreparedStatement findNodesByParentIdCQ;
+
+ protected PreparedStatement findPropertiesByParentIdCQ;
+
+ protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
+
+ protected PreparedStatement findItemQPathByIdentifierCQ;
+
/**
* The comparator used to sort the value data
*/
@@ -657,6 +666,35 @@
return new QPath(qentries);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void closeStatements() throws SQLException
+ {
+ super.closeStatements();
+
+ if (findNodesByParentIdCQ != null)
+ {
+ findNodesByParentIdCQ.close();
+ }
+
+ if (findPropertiesByParentIdCQ != null)
+ {
+ findPropertiesByParentIdCQ.close();
+ }
+
+ if (findNodeMainPropertiesByParentIdentifierCQ != null)
+ {
+ findNodeMainPropertiesByParentIdentifierCQ.close();
+ }
+
+ if (findItemQPathByIdentifierCQ != null)
+ {
+ findItemQPathByIdentifierCQ.close();
+ }
+ }
+
protected abstract ResultSet findItemQPathByIdentifierCQ(String identifier) throws
SQLException;
protected abstract ResultSet findChildNodesByParentIdentifierCQ(String
parentIdentifier) throws SQLException;
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-05-26
13:39:19 UTC (rev 2437)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-05-26
14:31:13 UTC (rev 2438)
@@ -31,7 +31,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@@ -63,74 +62,6 @@
+ " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN
JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ " where I.I_CLASS=2 and I.PARENT_ID=? order by I.NAME";
- protected PreparedStatement findItemById;
-
- protected PreparedStatement findItemByPath;
-
- protected PreparedStatement findItemByName;
-
- protected PreparedStatement findChildPropertyByPath;
-
- protected PreparedStatement findPropertyByName;
-
- protected PreparedStatement findDescendantNodes;
-
- protected PreparedStatement findDescendantProperties;
-
- protected PreparedStatement findReferences;
-
- protected PreparedStatement findValuesByPropertyId;
-
- protected PreparedStatement findValuesDataByPropertyId;
-
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
-
- protected PreparedStatement findValueByPropertyIdOrderNumber;
-
- protected PreparedStatement findNodesByParentId;
-
- protected PreparedStatement findNodesByParentIdCQ;
-
- protected PreparedStatement findNodesCountByParentId;
-
- protected PreparedStatement findPropertiesByParentId;
-
- protected PreparedStatement findPropertiesByParentIdCQ;
-
- protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
-
- protected PreparedStatement findItemQPathByIdentifierCQ;
-
- protected PreparedStatement insertNode;
-
- protected PreparedStatement insertProperty;
-
- protected PreparedStatement insertReference;
-
- protected PreparedStatement insertValue;
-
- protected PreparedStatement updateItem;
-
- protected PreparedStatement updateItemPath;
-
- protected PreparedStatement updateNode;
-
- protected PreparedStatement updateProperty;
-
- protected PreparedStatement updateValue;
-
- protected PreparedStatement deleteItem;
-
- protected PreparedStatement deleteNode;
-
- protected PreparedStatement deleteProperty;
-
- protected PreparedStatement deleteReference;
-
- protected PreparedStatement deleteValue;
-
- protected PreparedStatement renameNode;
-
/**
* Multidatabase JDBC Connection constructor.
*
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-05-26
13:39:19 UTC (rev 2437)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-05-26
14:31:13 UTC (rev 2438)
@@ -30,7 +30,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
@@ -61,76 +60,6 @@
+ " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON
(V.PROPERTY_ID=I.ID)"
+ " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? order by
I.NAME";
- protected PreparedStatement findItemById;
-
- protected PreparedStatement findItemByPath;
-
- protected PreparedStatement findItemByName;
-
- protected PreparedStatement findChildPropertyByPath;
-
- protected PreparedStatement findPropertyByName;
-
- protected PreparedStatement findDescendantNodes;
-
- protected PreparedStatement findDescendantProperties;
-
- protected PreparedStatement findReferences;
-
- protected PreparedStatement findValuesByPropertyId;
-
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
-
- protected PreparedStatement findValuesDataByPropertyId;
-
- protected PreparedStatement findValueByPropertyIdOrderNumber;
-
- protected PreparedStatement findNodesByParentId;
-
- protected PreparedStatement findNodesByParentIdCQ;
-
- protected PreparedStatement findNodesCountByParentId;
-
- protected PreparedStatement findPropertiesByParentId;
-
- protected PreparedStatement findPropertiesByParentIdCQ;
-
- protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
-
- protected PreparedStatement findItemQPathByIdentifierCQ;
-
- protected PreparedStatement insertItem;
-
- protected PreparedStatement insertNode;
-
- protected PreparedStatement insertProperty;
-
- protected PreparedStatement insertReference;
-
- protected PreparedStatement insertValue;
-
- protected PreparedStatement updateItem;
-
- protected PreparedStatement updateItemPath;
-
- protected PreparedStatement updateNode;
-
- protected PreparedStatement updateProperty;
-
- protected PreparedStatement updateValue;
-
- protected PreparedStatement deleteItem;
-
- protected PreparedStatement deleteNode;
-
- protected PreparedStatement deleteProperty;
-
- protected PreparedStatement deleteReference;
-
- protected PreparedStatement deleteValue;
-
- protected PreparedStatement renameNode;
-
/**
* Singledatabase JDBC Connection constructor.
*
Show replies by date