Author: tv Date: Thu Aug 5 17:48:28 2010 New Revision: 982709 URL: http://svn.apache.org/viewvc?rev=982709&view=rev Log: Fix TORQUE-8: Village does not close every resultSet it opens.
Modified: db/torque/village/trunk/src/java/com/workingdogs/village/DataSet.java db/torque/village/trunk/src/java/com/workingdogs/village/Record.java db/torque/village/trunk/src/java/com/workingdogs/village/Schema.java db/torque/village/trunk/xdocs/changes.xml Modified: db/torque/village/trunk/src/java/com/workingdogs/village/DataSet.java URL: http://svn.apache.org/viewvc/db/torque/village/trunk/src/java/com/workingdogs/village/DataSet.java?rev=982709&r1=982708&r2=982709&view=diff ============================================================================== --- db/torque/village/trunk/src/java/com/workingdogs/village/DataSet.java (original) +++ db/torque/village/trunk/src/java/com/workingdogs/village/DataSet.java Thu Aug 5 17:48:28 2010 @@ -344,7 +344,7 @@ public abstract class DataSet releaseRecords(); this.schema = null; - if ((this.resultSet != null) && !(this instanceof QueryDataSet)) + if (this.resultSet != null) { resultSet().close(); } Modified: db/torque/village/trunk/src/java/com/workingdogs/village/Record.java URL: http://svn.apache.org/viewvc/db/torque/village/trunk/src/java/com/workingdogs/village/Record.java?rev=982709&r1=982708&r2=982709&view=diff ============================================================================== --- db/torque/village/trunk/src/java/com/workingdogs/village/Record.java (original) +++ db/torque/village/trunk/src/java/com/workingdogs/village/Record.java Thu Aug 5 17:48:28 2010 @@ -21,9 +21,7 @@ package com.workingdogs.village; import java.io.ByteArrayOutputStream; import java.io.PrintWriter; - import java.math.BigDecimal; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -1495,7 +1493,8 @@ public class Record } PreparedStatement stmt = null; - + ResultSet rs = null; + try { stmt = connection.prepareStatement(getRefreshQueryString()); @@ -1514,19 +1513,29 @@ public class Record val.setPreparedStatementValue(stmt, ps++); } - ResultSet rs = stmt.executeQuery(); + rs = stmt.executeQuery(); rs.next(); initializeRecord(); createValues(rs); } - catch (SQLException e1) - { - throw e1; - } finally { + SQLException sqlEx = null; + + try + { + if (rs != null) + { + rs.close(); + } + } + catch (SQLException e2) + { + sqlEx = e2; + } + try { if (stmt != null) @@ -1536,7 +1545,12 @@ public class Record } catch (SQLException e2) { - throw e2; + sqlEx = e2; + } + + if (sqlEx != null) + { + throw sqlEx; } } } Modified: db/torque/village/trunk/src/java/com/workingdogs/village/Schema.java URL: http://svn.apache.org/viewvc/db/torque/village/trunk/src/java/com/workingdogs/village/Schema.java?rev=982709&r1=982708&r2=982709&view=diff ============================================================================== --- db/torque/village/trunk/src/java/com/workingdogs/village/Schema.java (original) +++ db/torque/village/trunk/src/java/com/workingdogs/village/Schema.java Thu Aug 5 17:48:28 2010 @@ -113,6 +113,7 @@ public final class Schema } Statement stmt = null; + ResultSet rs = null; try { @@ -124,7 +125,7 @@ public final class Schema String sql = "SELECT " + columnsAttribute + " FROM " + tableName + " WHERE 1 = -1"; stmt = conn.createStatement(); - ResultSet rs = stmt.executeQuery(sql); + rs = stmt.executeQuery(sql); if (rs != null) { @@ -144,9 +145,27 @@ public final class Schema } finally { + if (rs != null) + { + try + { + rs.close(); + } + catch (SQLException e) + { + //Do nothing + } + } if (stmt != null) { - stmt.close(); + try + { + stmt.close(); + } + catch (SQLException e) + { + //Do nothing + } } } } Modified: db/torque/village/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/db/torque/village/trunk/xdocs/changes.xml?rev=982709&r1=982708&r2=982709&view=diff ============================================================================== --- db/torque/village/trunk/xdocs/changes.xml (original) +++ db/torque/village/trunk/xdocs/changes.xml Thu Aug 5 17:48:28 2010 @@ -25,6 +25,9 @@ <body> <release version="3.3.1-SNAPSHOT" date="in SVN"> + <action type="fix" dev="tv" issue="TORQUE-8"> + Fixed: Village does not close every resultSet it opens. + </action> <action type="fix" dev="seade" issue="TORQUE-133" due-to="Georg Marx"> Deal with situation arising in jre1.6.0_18 where an IllegalArgumentException is encountered for dates with a single digit --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org