Author: tolusha
Date: 2010-06-09 09:48:33 -0400 (Wed, 09 Jun 2010)
New Revision: 2527
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
Log:
EXOJCR-754: close Statements & ResultSets
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -34,6 +34,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -226,25 +227,52 @@
try
{
Connection con = openConnection();
- if (isDbInitialized(con))
+ ResultSet res = null;
+ PreparedStatement ps = null;
+ try
{
- // check that data exists
- PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM "
+ configTableName + " WHERE NAME=?");
- try
+ if (isDbInitialized(con))
{
+ // check that data exists
+ ps = con.prepareStatement("SELECT COUNT(*) FROM " +
configTableName + " WHERE NAME=?");
+
ps.setString(1, CONFIGNAME);
- ResultSet res = ps.executeQuery();
+ res = ps.executeQuery();
if (res.next())
{
return res.getInt(1) > 0;
}
}
- finally
+ return false;
+ }
+ finally
+ {
+ if (res != null)
{
- con.close();
+ try
+ {
+ res.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
+ con.close();
}
- return false;
}
catch (final SQLException e)
{
@@ -264,14 +292,16 @@
try
{
Connection con = openConnection();
+ ResultSet res = null;
+ PreparedStatement ps = null;
try
{
if (isDbInitialized(con))
{
- PreparedStatement ps = con.prepareStatement("SELECT * FROM " +
configTableName + " WHERE NAME=?");
+ ps = con.prepareStatement("SELECT * FROM " + configTableName +
" WHERE NAME=?");
ps.setString(1, CONFIGNAME);
- ResultSet res = ps.executeQuery();
+ res = ps.executeQuery();
if (res.next())
{
@@ -281,7 +311,6 @@
else
throw new ConfigurationNotFoundException("No configuration data is
found in database. Source name "
+ sourceName);
-
}
else
throw new ConfigurationNotInitializedException(
@@ -290,6 +319,30 @@
}
finally
{
+ if (res != null)
+ {
+ try
+ {
+ res.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -316,6 +369,7 @@
try
{
Connection con = openConnection();
+ PreparedStatement ps = null;
try
{
@@ -324,7 +378,9 @@
if (!isDbInitialized(con))
{
// init db
- con.createStatement().executeUpdate(sql = initSQL);
+ Statement st = con.createStatement();
+ st.executeUpdate(sql = initSQL);
+ st.close();
con.commit();
con.close();
@@ -336,9 +392,6 @@
if (isDbInitialized(con))
{
-
- PreparedStatement ps = null;
-
ConfigDataHolder config = new ConfigDataHolder(confData);
if (hasConfig())
@@ -372,6 +425,18 @@
}
finally
{
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -330,6 +330,8 @@
checkIfOpened();
try
{
+ closeStatements();
+
if (!this.readOnly)
{
dbConnection.rollback();
@@ -386,156 +388,163 @@
*
* @throws SQLException
*/
- protected void closeStatements() throws SQLException
+ protected void closeStatements()
{
- if (findItemById != null)
+ try
{
- findItemById.close();
- }
+ if (findItemById != null)
+ {
+ findItemById.close();
+ }
- if (findItemByPath != null)
- {
- findItemByPath.close();
- }
+ if (findItemByPath != null)
+ {
+ findItemByPath.close();
+ }
- if (findItemByName != null)
- {
- findItemByName.close();
- }
+ if (findItemByName != null)
+ {
+ findItemByName.close();
+ }
- if (findChildPropertyByPath != null)
- {
- findChildPropertyByPath.close();
- }
+ if (findChildPropertyByPath != null)
+ {
+ findChildPropertyByPath.close();
+ }
- if (findPropertyByName != null)
- {
- findPropertyByName.close();
- }
+ if (findPropertyByName != null)
+ {
+ findPropertyByName.close();
+ }
- if (findDescendantNodes != null)
- {
- findDescendantNodes.close();
- }
+ if (findDescendantNodes != null)
+ {
+ findDescendantNodes.close();
+ }
- if (findDescendantProperties != null)
- {
- findDescendantProperties.close();
- }
+ if (findDescendantProperties != null)
+ {
+ findDescendantProperties.close();
+ }
- if (findReferences != null)
- {
- findReferences.close();
- }
+ if (findReferences != null)
+ {
+ findReferences.close();
+ }
- if (findValuesByPropertyId != null)
- {
- findValuesByPropertyId.close();
- }
+ if (findValuesByPropertyId != null)
+ {
+ findValuesByPropertyId.close();
+ }
- if (findValuesStorageDescriptorsByPropertyId != null)
- {
- findValuesStorageDescriptorsByPropertyId.close();
- }
+ if (findValuesStorageDescriptorsByPropertyId != null)
+ {
+ findValuesStorageDescriptorsByPropertyId.close();
+ }
- if (findValuesDataByPropertyId != null)
- {
- findValuesDataByPropertyId.close();
- }
+ if (findValuesDataByPropertyId != null)
+ {
+ findValuesDataByPropertyId.close();
+ }
- if (findValueByPropertyIdOrderNumber != null)
- {
- findValueByPropertyIdOrderNumber.close();
- }
+ if (findValueByPropertyIdOrderNumber != null)
+ {
+ findValueByPropertyIdOrderNumber.close();
+ }
- if (findNodesByParentId != null)
- {
- findNodesByParentId.close();
- }
+ if (findNodesByParentId != null)
+ {
+ findNodesByParentId.close();
+ }
- if (findNodesCountByParentId != null)
- {
- findNodesCountByParentId.close();
- }
+ if (findNodesCountByParentId != null)
+ {
+ findNodesCountByParentId.close();
+ }
- if (findPropertiesByParentId != null)
- {
- findPropertiesByParentId.close();
- }
+ if (findPropertiesByParentId != null)
+ {
+ findPropertiesByParentId.close();
+ }
- if (insertItem != null)
- {
- insertItem.close();
- }
+ if (insertItem != null)
+ {
+ insertItem.close();
+ }
- if (insertNode != null)
- {
- insertNode.close();
- }
+ if (insertNode != null)
+ {
+ insertNode.close();
+ }
- if (insertProperty != null)
- {
- insertProperty.close();
- }
+ if (insertProperty != null)
+ {
+ insertProperty.close();
+ }
- if (insertReference != null)
- {
- insertReference.close();
- }
+ if (insertReference != null)
+ {
+ insertReference.close();
+ }
- if (insertValue != null)
- {
- insertValue.close();
- }
+ if (insertValue != null)
+ {
+ insertValue.close();
+ }
- if (updateItem != null)
- {
- updateItem.close();
- }
+ if (updateItem != null)
+ {
+ updateItem.close();
+ }
- if (updateItemPath != null)
- {
- updateItemPath.close();
- }
+ if (updateItemPath != null)
+ {
+ updateItemPath.close();
+ }
- if (updateNode != null)
- {
- updateNode.close();
- }
+ if (updateNode != null)
+ {
+ updateNode.close();
+ }
- if (updateProperty != null)
- {
- updateProperty.close();
- }
+ if (updateProperty != null)
+ {
+ updateProperty.close();
+ }
- if (deleteItem != null)
- {
- deleteItem.close();
- }
+ if (deleteItem != null)
+ {
+ deleteItem.close();
+ }
- if (deleteNode != null)
- {
- deleteNode.close();
- }
+ if (deleteNode != null)
+ {
+ deleteNode.close();
+ }
- if (deleteProperty != null)
- {
- deleteProperty.close();
- }
+ if (deleteProperty != null)
+ {
+ deleteProperty.close();
+ }
- if (deleteReference != null)
- {
- deleteReference.close();
- }
+ if (deleteReference != null)
+ {
+ deleteReference.close();
+ }
- if (deleteValue != null)
- {
- deleteValue.close();
+ if (deleteValue != null)
+ {
+ deleteValue.close();
+ }
+
+ if (renameNode != null)
+ {
+ renameNode.close();
+ }
}
-
- if (renameNode != null)
+ catch (SQLException e)
{
- renameNode.close();
+ LOG.error("Can't close the statement: " + e);
}
}
@@ -547,6 +556,8 @@
checkIfOpened();
try
{
+ closeStatements();
+
if (!this.readOnly)
{
dbConnection.commit();
@@ -877,13 +888,27 @@
try
{
ResultSet node =
findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<NodeData> childrens = new ArrayList<NodeData>();
- while (node.next())
+ try
{
- childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE,
parent.getACL()));
+ List<NodeData> childrens = new ArrayList<NodeData>();
+ while (node.next())
+ {
+ childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE,
parent.getACL()));
+ }
+
+ return childrens;
}
-
- return childrens;
+ finally
+ {
+ try
+ {
+ node.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -904,13 +929,28 @@
try
{
ResultSet count =
findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
- if (count.next())
+ try
{
- return count.getInt(1);
+ if (count.next())
+ {
+ return count.getInt(1);
+ }
+ else
+ {
+ throw new RepositoryException("FATAL No resulton childNodes count for
"
+ + parent.getQPath().getAsString());
+ }
}
- else
+ finally
{
- throw new RepositoryException("FATAL No resulton childNodes count for
" + parent.getQPath().getAsString());
+ try
+ {
+ count.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
catch (SQLException e)
@@ -928,11 +968,25 @@
try
{
ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- children.add((PropertyData)itemData(parent.getQPath(), prop,
I_CLASS_PROPERTY, null));
+ try
+ {
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ children.add((PropertyData)itemData(parent.getQPath(), prop,
I_CLASS_PROPERTY, null));
- return children;
+ return children;
+ }
+ finally
+ {
+ try
+ {
+ prop.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -953,11 +1007,25 @@
try
{
ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- children.add(propertyData(parent.getQPath(), prop));
+ try
+ {
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ children.add(propertyData(parent.getQPath(), prop));
- return children;
+ return children;
+ }
+ finally
+ {
+ try
+ {
+ prop.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -998,12 +1066,26 @@
try
{
ResultSet refProps = findReferences(getInternalId(nodeIdentifier));
- List<PropertyData> references = new ArrayList<PropertyData>();
- while (refProps.next())
+ try
{
- references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
+ List<PropertyData> references = new ArrayList<PropertyData>();
+ while (refProps.next())
+ {
+ references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
+ }
+ return references;
}
- return references;
+ finally
+ {
+ try
+ {
+ refProps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -1038,13 +1120,20 @@
return valueRecord.wasNull() ? readValueData(cid, orderNumb,
persistedVersion, valueRecord
.getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb,
storageId);
}
+
+ return null;
}
finally
{
- valueRecord.close();
+ try
+ {
+ valueRecord.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
-
- return null;
}
catch (SQLException e)
{
@@ -1072,15 +1161,28 @@
protected ItemData getItemByIdentifier(String cid) throws RepositoryException,
IllegalStateException
{
checkIfOpened();
- ResultSet item = null;
try
{
- item = findItemByIdentifier(cid);
- if (item.next())
+ ResultSet item = findItemByIdentifier(cid);
+ try
{
- return itemData(null, item, item.getInt(COLUMN_CLASS), null);
+ if (item.next())
+ {
+ return itemData(null, item, item.getInt(COLUMN_CLASS), null);
+ }
+ return null;
}
- return null;
+ finally
+ {
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -1090,18 +1192,6 @@
{
throw new RepositoryException("getItemData() error", e);
}
- finally
- {
- try
- {
- if (item != null)
- item.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " +
e.getMessage());
- }
- }
}
/**
@@ -1123,13 +1213,26 @@
IllegalStateException
{
checkIfOpened();
- ResultSet item = null;
try
{
- item = findItemByName(parentId, name.getAsString(), name.getIndex());
- if (item.next())
- return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS),
parent.getACL());
- return null;
+ ResultSet item = findItemByName(parentId, name.getAsString(), name.getIndex());
+ try
+ {
+ if (item.next())
+ return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS),
parent.getACL());
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -1139,18 +1242,6 @@
{
throw new RepositoryException(e);
}
- finally
- {
- try
- {
- if (item != null)
- item.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " +
e.getMessage());
- }
- }
}
/**
@@ -1183,10 +1274,9 @@
String caid = cpid; // container ancestor id
do
{
- ResultSet parent = null;
+ ResultSet parent = findItemByIdentifier(caid);
try
{
- parent = findItemByIdentifier(caid);
if (!parent.next())
throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(caid));
@@ -1197,7 +1287,14 @@
}
finally
{
- parent.close();
+ try
+ {
+ parent.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
while (!caid.equals(Constants.ROOT_PARENT_UUID));
@@ -1296,7 +1393,14 @@
}
finally
{
- pidrs.close();
+ try
+ {
+ pidrs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1426,6 +1530,7 @@
{
List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted
path
PreparedStatement cstmt = null;
+ ResultSet parent = null;
try
{
cstmt =
@@ -1433,7 +1538,7 @@
.prepareStatement("select * from get_qpath(?) AS (id varchar, name
varchar, parent_id varchar, i_index int)");
cstmt.setString(1, cpid);
// cstmt.setString(2, caid);
- ResultSet parent = cstmt.executeQuery();
+ parent = cstmt.executeQuery();
while (parent.next())
{
@@ -1445,9 +1550,22 @@
// parent = findItemByIdentifier(caid);
if (qrpath.size() <= 0)
throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(cpid));
+
}
finally
{
+ if (parent != null)
+ {
+ try
+ {
+ parent.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (cstmt != null)
cstmt.close();
}
@@ -1706,7 +1824,14 @@
}
finally
{
- mtrs.close();
+ try
+ {
+ mtrs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1745,7 +1870,14 @@
}
finally
{
- exoPerm.close();
+ try
+ {
+ exoPerm.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1772,7 +1904,14 @@
}
finally
{
- exoOwner.close();
+ try
+ {
+ exoOwner.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1833,10 +1972,10 @@
}
}
+ // PRIMARY
+ ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
try
{
- // PRIMARY
- ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
if (!ptProp.next())
throw new PrimaryTypeNotFoundException("FATAL ERROR primary type
record not found. Node "
@@ -1914,6 +2053,17 @@
throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
+ " has wrong formed ACL. ", e);
}
+ finally
+ {
+ try
+ {
+ ptProp.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (IllegalNameException e)
{
@@ -2020,7 +2170,14 @@
}
finally
{
- valueRecords.close();
+ try
+ {
+ valueRecords.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -2062,7 +2219,14 @@
}
finally
{
- valueRecords.close();
+ try
+ {
+ valueRecords.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
return data;
@@ -2119,8 +2283,6 @@
throws SQLException, IOException
{
- ResultSet valueResultSet = null;
-
byte[] buffer = new byte[0];
byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
int read;
@@ -2170,8 +2332,6 @@
}
finally
{
- if (valueResultSet != null)
- valueResultSet.close();
if (out != null)
{
out.close();
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -22,6 +22,7 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
/**
* Created by The eXo Platform SAS
@@ -68,14 +69,16 @@
protected boolean isSequenceExists(Connection conn, String sequenceName) throws
SQLException
{
String seqName = sequenceName.toUpperCase().toLowerCase();
+ ResultSet srs = null;
+ Statement st = null;
try
{
- ResultSet srs = conn.createStatement().executeQuery("SELECT NEXT VALUE FOR
" + seqName);
+ st = conn.createStatement();
+ srs = st.executeQuery("SELECT NEXT VALUE FOR " + seqName);
if (srs.next())
{
return true;
}
- srs.close();
return false;
}
catch (final SQLException e)
@@ -85,7 +88,6 @@
return false;
throw new SQLException(e.getMessage())
{
-
/**
* {@inheritDoc}
*/
@@ -96,6 +98,32 @@
}
};
}
+ finally
+ {
+ if (srs != null)
+ {
+ try
+ {
+ srs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
}
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -22,6 +22,7 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
/**
* Created by The eXo Platform SAS
@@ -46,14 +47,16 @@
@Override
protected boolean isSequenceExists(Connection conn, String sequenceName) throws
SQLException
{
+ ResultSet srs = null;
+ Statement st = null;
try
{
- ResultSet srs = conn.createStatement().executeQuery("SELECT " +
sequenceName + ".nextval FROM DUAL");
+ st = conn.createStatement();
+ srs = st.executeQuery("SELECT " + sequenceName + ".nextval FROM
DUAL");
if (srs.next())
{
return true;
}
- srs.close();
return false;
}
catch (SQLException e)
@@ -63,25 +66,86 @@
return false;
throw e;
}
+ finally
+ {
+ if (srs != null)
+ {
+ try
+ {
+ srs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
@Override
protected boolean isTriggerExists(Connection conn, String triggerName) throws
SQLException
{
String sql = "SELECT COUNT(trigger_name) FROM all_triggers WHERE trigger_name
= '" + triggerName + "'";
- ResultSet r = conn.createStatement().executeQuery(sql);
- if (r.next())
- return r.getInt(1) > 0;
- else
- return false;
+ Statement st = null;
+ ResultSet r = null;
+ try
+ {
+ st = conn.createStatement();
+ r = st.executeQuery(sql);
+
+ if (r.next())
+ return r.getInt(1) > 0;
+ else
+ return false;
+ }
+ finally
+ {
+ if (r != null)
+ {
+ try
+ {
+ r.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
@Override
protected boolean isTableExists(Connection conn, String tableName) throws
SQLException
{
+ Statement st = null;
try
{
- conn.createStatement().executeUpdate("SELECT 1 FROM " + tableName);
+ st = conn.createStatement();
+ st.executeUpdate("SELECT 1 FROM " + tableName);
return true;
}
catch (SQLException e)
@@ -91,6 +155,20 @@
return false;
throw e;
}
+ finally
+ {
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
@Override
@@ -98,10 +176,44 @@
{
// use of oracle system view
String sql = "SELECT COUNT(index_name) FROM all_indexes WHERE
index_name='" + indexName + "'";
- ResultSet r = conn.createStatement().executeQuery(sql);
- if (r.next())
- return r.getInt(1) > 0;
- else
- return false;
+ Statement st = null;
+ ResultSet r = null;
+ try
+ {
+ st = conn.createStatement();
+ r = st.executeQuery(sql);
+
+ if (r.next())
+ return r.getInt(1) > 0;
+ else
+ return false;
+ }
+ finally
+ {
+ if (r != null)
+ {
+ try
+ {
+ r.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
+ }
}
}
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -248,7 +248,7 @@
}
catch (SQLException e)
{
- LOG.error(e.getMessage(), e);
+ LOG.error("Can't close the ResultSet: " + e);
}
}
}
@@ -348,7 +348,7 @@
}
catch (SQLException e)
{
- LOG.error(e.getMessage(), e);
+ LOG.error("Can't close the ResultSet: " + e);
}
}
}
@@ -409,20 +409,34 @@
int cversion, int cnordernumb, AccessControlList parentACL) throws
RepositoryException, SQLException
{
ResultSet ptProp = findNodeMainPropertiesByParentIdentifierCQ(cid);
- Map<String, SortedSet<TempPropertyData>> properties = new
HashMap<String, SortedSet<TempPropertyData>>();
- while (ptProp.next())
+ try
{
- String key = ptProp.getString(COLUMN_NAME);
- SortedSet<TempPropertyData> values = properties.get(key);
- if (values == null)
+ Map<String, SortedSet<TempPropertyData>> properties = new
HashMap<String, SortedSet<TempPropertyData>>();
+ while (ptProp.next())
{
- values = new TreeSet<TempPropertyData>();
- properties.put(key, values);
+ String key = ptProp.getString(COLUMN_NAME);
+ SortedSet<TempPropertyData> values = properties.get(key);
+ if (values == null)
+ {
+ values = new TreeSet<TempPropertyData>();
+ properties.put(key, values);
+ }
+ values.add(new TempPropertyData(ptProp));
}
- values.add(new TempPropertyData(ptProp));
+
+ return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion,
cnordernumb, properties, parentACL);
}
-
- return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb,
properties, parentACL);
+ finally
+ {
+ try
+ {
+ ptProp.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
/**
@@ -644,8 +658,19 @@
}
finally
{
- result.close();
+ if (result != null)
+ {
+ try
+ {
+ result.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
+
if (caid.equals(Constants.ROOT_PARENT_UUID) || (id =
getIdentifier(caid)).equals(Constants.ROOT_UUID))
{
if (id.equals(Constants.ROOT_UUID))
@@ -670,28 +695,35 @@
* {@inheritDoc}
*/
@Override
- protected void closeStatements() throws SQLException
+ protected void closeStatements()
{
super.closeStatements();
- if (findNodesByParentIdCQ != null)
+ try
{
- findNodesByParentIdCQ.close();
- }
+ if (findNodesByParentIdCQ != null)
+ {
+ findNodesByParentIdCQ.close();
+ }
- if (findPropertiesByParentIdCQ != null)
- {
- findPropertiesByParentIdCQ.close();
- }
+ if (findPropertiesByParentIdCQ != null)
+ {
+ findPropertiesByParentIdCQ.close();
+ }
- if (findNodeMainPropertiesByParentIdentifierCQ != null)
- {
- findNodeMainPropertiesByParentIdentifierCQ.close();
+ if (findNodeMainPropertiesByParentIdentifierCQ != null)
+ {
+ findNodeMainPropertiesByParentIdentifierCQ.close();
+ }
+
+ if (findItemQPathByIdentifierCQ != null)
+ {
+ findItemQPathByIdentifierCQ.close();
+ }
}
-
- if (findItemQPathByIdentifierCQ != null)
+ catch (SQLException e)
{
- findItemQPathByIdentifierCQ.close();
+ LOG.error("Can't close the Statement: " + e);
}
}
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -30,6 +30,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
@@ -199,6 +200,7 @@
PreparedStatement insertVersion =
connection.prepareStatement(SQL_UPDATE_VERSION);
insertVersion.setString(1, REQUIRED_STORAGE_VERSION);
insertVersion.executeUpdate();
+ insertVersion.close();
connection.commit();
}
@@ -368,9 +370,11 @@
private String currentVersion() throws SQLException
{
ResultSet version = null;
+ Statement st = null;
try
{
- version = connection.createStatement().executeQuery(SQL_SELECT_VERSION);
+ st = connection.createStatement();
+ version = st.executeQuery(SQL_SELECT_VERSION);
if (version.next())
return version.getString("VERSION");
}
@@ -381,12 +385,34 @@
finally
{
if (version != null)
- version.close();
+ {
+ try
+ {
+ version.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
PreparedStatement insertVersion = connection.prepareStatement(SQL_INSERT_VERSION);
insertVersion.setString(1, REQUIRED_STORAGE_VERSION);
insertVersion.executeUpdate();
+ insertVersion.close();
return REQUIRED_STORAGE_VERSION;
}
@@ -402,9 +428,11 @@
ResultSet refs = null;
PreparedStatement update = null;
+ Statement st = null;
try
{
- refs = conn.createStatement().executeQuery(SQL_SELECT_JCRUUID);
+ st = conn.createStatement();
+ refs = st.executeQuery(SQL_SELECT_JCRUUID);
update = conn.prepareStatement(SQL_UPDATE_JCRUUID);
while (refs.next())
{
@@ -453,9 +481,40 @@
finally
{
if (refs != null)
- refs.close();
+ {
+ try
+ {
+ refs.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (update != null)
- update.close();
+ {
+ try
+ {
+ update.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
}
@@ -467,10 +526,12 @@
ResultSet refs = null;
PreparedStatement update = null;
+ Statement st = null;
try
{
String sql = SQL_SELECT_FROZENJCRUUID.replaceAll(FROZENJCRUUID,
searchCriteria);
- refs = conn.createStatement().executeQuery(SQL_SELECT_FROZENJCRUUID);
+ st = conn.createStatement();
+ refs = st.executeQuery(SQL_SELECT_FROZENJCRUUID);
while (refs.next())
{
try
@@ -502,9 +563,40 @@
finally
{
if (refs != null)
- refs.close();
+ {
+ try
+ {
+ refs.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (update != null)
- update.close();
+ {
+ try
+ {
+ update.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
}
@@ -518,9 +610,11 @@
ResultSet refs = null;
PreparedStatement update = null;
+ Statement st = null;
try
{
- refs = conn.createStatement().executeQuery(SQL_SELECT_REFERENCES);
+ st = conn.createStatement();
+ refs = st.executeQuery(SQL_SELECT_REFERENCES);
update = conn.prepareStatement(SQL_INSERT_REFERENCES);
while (refs.next())
{
@@ -562,9 +656,40 @@
finally
{
if (refs != null)
- refs.close();
+ {
+ try
+ {
+ refs.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (update != null)
- update.close();
+ {
+ try
+ {
+ update.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
}
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -29,6 +29,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -142,6 +143,7 @@
{
dataSource = (DataSource)new InitialContext().lookup(sn);
Connection conn = null;
+ Statement st = null;
try
{
conn = dataSource.getConnection();
@@ -204,15 +206,15 @@
// check if table already exists
if (!trs.next())
{
+ st = conn.createStatement();
+
// create table
- conn.createStatement().executeUpdate(
- "CREATE TABLE " + tableName
- + " (PROPERTY_ID VARCHAR(96) NOT NULL, ORDER_NUM INTEGER NOT
NULL, CAS_ID VARCHAR(512) NOT NULL, "
- + "CONSTRAINT " + sqlConstraintPK + " PRIMARY
KEY(PROPERTY_ID, ORDER_NUM))");
+ st.executeUpdate("CREATE TABLE " + tableName
+ + " (PROPERTY_ID VARCHAR(96) NOT NULL, ORDER_NUM INTEGER NOT NULL,
CAS_ID VARCHAR(512) NOT NULL, "
+ + "CONSTRAINT " + sqlConstraintPK + " PRIMARY
KEY(PROPERTY_ID, ORDER_NUM))");
// create index on hash (CAS_ID)
- conn.createStatement().executeUpdate(
- "CREATE INDEX " + sqlVCASIDX + " ON " + tableName +
"(CAS_ID, PROPERTY_ID, ORDER_NUM)");
+ st.executeUpdate("CREATE INDEX " + sqlVCASIDX + " ON "
+ tableName + "(CAS_ID, PROPERTY_ID, ORDER_NUM)");
if (LOG.isDebugEnabled())
{
@@ -230,6 +232,18 @@
}
finally
{
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
if (conn != null)
{
try
@@ -403,12 +417,14 @@
try
{
Connection con = dataSource.getConnection();
+ ResultSet rs = null;
+ PreparedStatement ps = null;
try
{
- PreparedStatement ps = con.prepareStatement(sqlSelectRecord);
+ ps = con.prepareStatement(sqlSelectRecord);
ps.setString(1, propertyId);
ps.setInt(2, orderNum);
- ResultSet rs = ps.executeQuery();
+ rs = ps.executeQuery();
if (rs.next())
{
@@ -422,6 +438,30 @@
}
finally
{
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -439,16 +479,17 @@
try
{
Connection con = dataSource.getConnection();
+ PreparedStatement ps = null;
+ ResultSet rs = null;
try
{
List<String> ids = new ArrayList<String>();
- PreparedStatement ps;
if (ownOnly)
{
ps = con.prepareStatement(sqlSelectOwnRecords);
ps.setString(1, propertyId);
- ResultSet rs = ps.executeQuery();
+ rs = ps.executeQuery();
if (rs.next())
{
do
@@ -470,7 +511,7 @@
// TODO unused externaly feature (except tests)
ps = con.prepareStatement(sqlSelectRecords);
ps.setString(1, propertyId);
- ResultSet rs = ps.executeQuery();
+ rs = ps.executeQuery();
if (rs.next())
{
do
@@ -488,6 +529,30 @@
}
finally
{
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -505,14 +570,27 @@
try
{
Connection con = dataSource.getConnection();
+ PreparedStatement ps = null;
try
{
- PreparedStatement ps = con.prepareStatement(sqlSelectSharingProps);
+ ps = con.prepareStatement(sqlSelectSharingProps);
ps.setString(1, propertyId);
return ps.executeQuery().next();
}
finally
{
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -521,5 +599,4 @@
throw new VCASException("VCAS HAS SHARED IDs database error: " + e,
e);
}
}
-
}
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
---
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-09
13:47:50 UTC (rev 2526)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-09
13:48:33 UTC (rev 2527)
@@ -28,6 +28,7 @@
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -324,8 +325,10 @@
}
String sql = null;
+ Statement st = null;
try
{
+ st = connection.createStatement();
connection.setAutoCommit(false);
for (String scr : scripts)
@@ -341,7 +344,7 @@
LOG.debug("Execute script: \n[" + sql + "]");
}
- connection.createStatement().executeUpdate(sql);
+ st.executeUpdate(sql);
}
}
@@ -377,6 +380,18 @@
}
finally
{
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
try
{
connection.close();