[jira] Resolved: (TORQUE-123) Statement is left open when Exception is thrown in the QueryDataSet constructor (ORA-01000)

2010-08-05 Thread Thomas Vandahl (JIRA)

 [ 
https://issues.apache.org/jira/browse/TORQUE-123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Vandahl resolved TORQUE-123.
---

Fix Version/s: 3.3.1
   Resolution: Fixed

Applied slightly simplified patch

> Statement  is left open when Exception is thrown in the QueryDataSet 
> constructor  (ORA-01000)
> -
>
> Key: TORQUE-123
> URL: https://issues.apache.org/jira/browse/TORQUE-123
> Project: Torque
>  Issue Type: Bug
>  Components: Village
>Affects Versions: 3.3
> Environment: OS  :RedHat Enterprise Linux ES 4 update 4
> Java  :1.4.2_08
> Tomcat:4.1.31
> Torque:3.0.2
> JDBC(Oracle): ojdbc.jar(10.2.0.4)
>Reporter: Kazu Nambo
>Assignee: Thomas Vandahl
> Fix For: 3.3.1
>
>
> When syntax error(SQLException) happens at executeQuery in the constructor 
> QueryDataSet(Connection conn, String selectStmt), the member stmt is left 
> open and this problem sometimes results in ORA-01000 (Maximum open cursors 
> exceeded).
> In the upper layer like BasePeer#executeQuery method, it tries to close 
> QueryDataSet instance by VillageUtils.close but it fails because the instance 
> is null.
> Other exceptions may result in the same situation.
> If I try to make the constructor more robust as follows, it will work. (No 
> ORA-01000)
> public QueryDataSet(Connection conn, String selectStmt)
> throws SQLException, DataSetException
> {
> this.conn = conn;
> selectString = new StringBuffer(selectStmt);
> try 
> {
>   stmt = conn.createStatement();
>   resultSet = stmt.executeQuery(selectStmt);
>   schema = new Schema();
>   schema.populate(resultSet.getMetaData(), null);
> }
> catch (Exception e)
> {
>   try {
>   if (null != resultSet) {
>   resultSet.close();
>   }
>   } catch (Exception ignored) {}
>   try {
>   if (null != stmt) {
>   stmt.close();
>   }
>   } catch (Exception ignored) {}
>   if (e instanceof SQLException)
>   throw (SQLException)e;
>   else if (e instanceof DataSetException)
>   throw (DataSetException)e;
>   else
>   throw new SQLException("QueryDataSet: exception 
> caught.", e);
> }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org



[jira] Assigned: (TORQUE-123) Statement is left open when Exception is thrown in the QueryDataSet constructor (ORA-01000)

2010-08-05 Thread Thomas Vandahl (JIRA)

 [ 
https://issues.apache.org/jira/browse/TORQUE-123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Vandahl reassigned TORQUE-123:
-

Assignee: Thomas Vandahl

> Statement  is left open when Exception is thrown in the QueryDataSet 
> constructor  (ORA-01000)
> -
>
> Key: TORQUE-123
> URL: https://issues.apache.org/jira/browse/TORQUE-123
> Project: Torque
>  Issue Type: Bug
>  Components: Village
>Affects Versions: 3.3
> Environment: OS  :RedHat Enterprise Linux ES 4 update 4
> Java  :1.4.2_08
> Tomcat:4.1.31
> Torque:3.0.2
> JDBC(Oracle): ojdbc.jar(10.2.0.4)
>Reporter: Kazu Nambo
>Assignee: Thomas Vandahl
>
> When syntax error(SQLException) happens at executeQuery in the constructor 
> QueryDataSet(Connection conn, String selectStmt), the member stmt is left 
> open and this problem sometimes results in ORA-01000 (Maximum open cursors 
> exceeded).
> In the upper layer like BasePeer#executeQuery method, it tries to close 
> QueryDataSet instance by VillageUtils.close but it fails because the instance 
> is null.
> Other exceptions may result in the same situation.
> If I try to make the constructor more robust as follows, it will work. (No 
> ORA-01000)
> public QueryDataSet(Connection conn, String selectStmt)
> throws SQLException, DataSetException
> {
> this.conn = conn;
> selectString = new StringBuffer(selectStmt);
> try 
> {
>   stmt = conn.createStatement();
>   resultSet = stmt.executeQuery(selectStmt);
>   schema = new Schema();
>   schema.populate(resultSet.getMetaData(), null);
> }
> catch (Exception e)
> {
>   try {
>   if (null != resultSet) {
>   resultSet.close();
>   }
>   } catch (Exception ignored) {}
>   try {
>   if (null != stmt) {
>   stmt.close();
>   }
>   } catch (Exception ignored) {}
>   if (e instanceof SQLException)
>   throw (SQLException)e;
>   else if (e instanceof DataSetException)
>   throw (DataSetException)e;
>   else
>   throw new SQLException("QueryDataSet: exception 
> caught.", e);
> }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org



svn commit: r982720 - in /db/torque/village/trunk: src/java/com/workingdogs/village/DataSet.java src/java/com/workingdogs/village/QueryDataSet.java xdocs/changes.xml

2010-08-05 Thread tv
Author: tv
Date: Thu Aug  5 18:14:08 2010
New Revision: 982720

URL: http://svn.apache.org/viewvc?rev=982720&view=rev
Log:
Fix TORQUE-123: Statement is left open when Exception is thrown in the 
QueryDataSet constructor

Modified:
db/torque/village/trunk/src/java/com/workingdogs/village/DataSet.java
db/torque/village/trunk/src/java/com/workingdogs/village/QueryDataSet.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=982720&r1=982719&r2=982720&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 18:14:08 2010
@@ -21,12 +21,10 @@ package com.workingdogs.village;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
-
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-
 import java.util.Vector;
 
 /**
@@ -343,20 +341,41 @@ public abstract class DataSet
 {
 releaseRecords();
 this.schema = null;
+
+SQLException sqlEx = null;
 
-if (this.resultSet != null)
+try 
 {
-resultSet().close();
-}
+   if (this.resultSet != null)
+   {
+   resultSet().close();
+   }
+   }
+catch (SQLException e)
+{
+   sqlEx = e;
+   }
 
-this.resultSet = null;
+   this.resultSet = null;
 
-if (this.stmt != null)
+try 
 {
-this.stmt.close();
-}
+   if (this.stmt != null)
+   {
+   this.stmt.close();
+   }
+   } 
+catch (SQLException e) 
+   {
+   sqlEx = e;
+   }
 
 this.conn = null;
+
+if (sqlEx != null)
+{
+   throw sqlEx;
+}
 }
 
 /**

Modified: 
db/torque/village/trunk/src/java/com/workingdogs/village/QueryDataSet.java
URL: 
http://svn.apache.org/viewvc/db/torque/village/trunk/src/java/com/workingdogs/village/QueryDataSet.java?rev=982720&r1=982719&r2=982720&view=diff
==
--- db/torque/village/trunk/src/java/com/workingdogs/village/QueryDataSet.java 
(original)
+++ db/torque/village/trunk/src/java/com/workingdogs/village/QueryDataSet.java 
Thu Aug  5 18:14:08 2010
@@ -76,10 +76,38 @@ public class QueryDataSet
 this.conn = conn;
 
 selectString = new StringBuffer(selectStmt);
-stmt = conn.createStatement();
-resultSet = stmt.executeQuery(selectStmt);
-schema = new Schema();
-schema.populate(resultSet.getMetaData(), null);
+
+try 
+{ 
+   stmt = conn.createStatement(); 
+   resultSet = stmt.executeQuery(selectStmt); 
+   schema = new Schema(); 
+   schema.populate(resultSet.getMetaData(), null); 
+} 
+catch (Exception e) 
+{ 
+   try 
+   {
+   close();
+   } 
+   catch (SQLException ignored)
+   {
+   // Do nothing
+   } 
+
+   if (e instanceof SQLException)
+   {
+   throw (SQLException)e;
+   }
+   else if (e instanceof DataSetException)
+   {
+   throw (DataSetException)e;
+   }
+   else
+   {
+   throw new SQLException("QueryDataSet: exception 
caught.", e);
+   }
+} 
 }
 
 /**

Modified: db/torque/village/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/db/torque/village/trunk/xdocs/changes.xml?rev=982720&r1=982719&r2=982720&view=diff
==
--- db/torque/village/trunk/xdocs/changes.xml (original)
+++ db/torque/village/trunk/xdocs/changes.xml Thu Aug  5 18:14:08 2010
@@ -25,6 +25,9 @@
 
   
   
+
+  Fixed: Statement is left open when Exception is thrown in the 
QueryDataSet constructor.
+
 
   Fixed: Village does not close every resultSet it opens.
 



-
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org



[jira] Resolved: (TORQUE-8) village does not close every resultSet it opens

2010-08-05 Thread Thomas Vandahl (JIRA)

 [ 
https://issues.apache.org/jira/browse/TORQUE-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Vandahl resolved TORQUE-8.
-

Fix Version/s: 3.3.1
   Resolution: Fixed

Applied patch and some cleanup

>  village does not close every resultSet it opens
> 
>
> Key: TORQUE-8
> URL: https://issues.apache.org/jira/browse/TORQUE-8
> Project: Torque
>  Issue Type: Bug
>  Components: Runtime, Village
>Affects Versions: 3.0, 3.1, 3.1.1, 3.2
>Reporter: Thomas Fischer
>Assignee: Thomas Vandahl
> Fix For: 3.3.1
>
> Attachments: village-2.0-TORQUE-8.patch, village-3.3-TORQUE-8.patch
>
>
> In the village classes Record and Schema, ResultSets are opened which are not 
> closed afterwards. This can lead to a "too many open cursors" error in 
> oracle. Thanks to Hendrik Busch for reporting the error.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org



[jira] Assigned: (TORQUE-8) village does not close every resultSet it opens

2010-08-05 Thread Thomas Vandahl (JIRA)

 [ 
https://issues.apache.org/jira/browse/TORQUE-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Vandahl reassigned TORQUE-8:
---

Assignee: Thomas Vandahl

>  village does not close every resultSet it opens
> 
>
> Key: TORQUE-8
> URL: https://issues.apache.org/jira/browse/TORQUE-8
> Project: Torque
>  Issue Type: Bug
>  Components: Runtime, Village
>Affects Versions: 3.0, 3.1, 3.1.1, 3.2
>Reporter: Thomas Fischer
>Assignee: Thomas Vandahl
> Attachments: village-2.0-TORQUE-8.patch, village-3.3-TORQUE-8.patch
>
>
> In the village classes Record and Schema, ResultSets are opened which are not 
> closed afterwards. This can lead to a "too many open cursors" error in 
> oracle. Thanks to Hendrik Busch for reporting the error.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


-
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org



svn commit: r982709 - in /db/torque/village/trunk: src/java/com/workingdogs/village/DataSet.java src/java/com/workingdogs/village/Record.java src/java/com/workingdogs/village/Schema.java xdocs/changes

2010-08-05 Thread tv
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)
+   {
+   /