Author: tolusha
Date: 2010-06-23 10:25:19 -0400 (Wed, 23 Jun 2010)
New Revision: 2692
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/util/jdbc/DBInitializer.java
Log:
EXOJCR-754: close unclosed 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-23
13:20:24 UTC (rev 2691)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-23
14:25:19 UTC (rev 2692)
@@ -211,7 +211,21 @@
try
{
ResultSet trs = con.getMetaData().getTables(null, null, configTableName, null);
- return trs.next();
+ try
+ {
+ return trs.next();
+ }
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException 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-23
13:20:24 UTC (rev 2691)
+++
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-23
14:25:19 UTC (rev 2692)
@@ -155,25 +155,53 @@
protected boolean isTableExists(Connection conn, String tableName) throws
SQLException
{
ResultSet trs = conn.getMetaData().getTables(null, null, tableName, null);
- boolean res = false;
- while (trs.next())
+ try
{
- res = true; // check for columns/table type matching etc.
+ boolean res = false;
+ while (trs.next())
+ {
+ res = true; // check for columns/table type matching etc.
+ }
+ return res;
}
- return res;
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
protected boolean isIndexExists(Connection conn, String tableName, String indexName)
throws SQLException
{
ResultSet irs = conn.getMetaData().getIndexInfo(null, null, tableName, false,
true);
- boolean res = false;
- while (irs.next())
+ try
{
- if (irs.getShort("TYPE") != DatabaseMetaData.tableIndexStatistic
- &&
irs.getString("INDEX_NAME").equalsIgnoreCase(indexName))
- res = true; // check for index params matching etc.
+ boolean res = false;
+ while (irs.next())
+ {
+ if (irs.getShort("TYPE") != DatabaseMetaData.tableIndexStatistic
+ &&
irs.getString("INDEX_NAME").equalsIgnoreCase(indexName))
+ res = true; // check for index params matching etc.
+ }
+ return res;
}
- return res;
+ finally
+ {
+ try
+ {
+ irs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
protected boolean isSequenceExists(Connection conn, String sequenceName) throws
SQLException
Show replies by date