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

2010-08-11 Thread Thomas Vandahl (JIRA)

[ 
https://issues.apache.org/jira/browse/TORQUE-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12897219#action_12897219
 ] 

Thomas Vandahl commented on TORQUE-123:
---

Thank you, that looks better. Care to commit it? Go ahead.

> 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 Fischer
> 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] Commented: (TORQUE-123) Statement is left open when Exception is thrown in the QueryDataSet constructor (ORA-01000)

2010-08-10 Thread Thomas Fischer (JIRA)

[ 
https://issues.apache.org/jira/browse/TORQUE-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12897014#action_12897014
 ] 

Thomas Fischer commented on TORQUE-123:
---

I'm going to use another patch:
boolean ok = false;
try
{
stmt = conn.createStatement();
resultSet = stmt.executeQuery(selectStmt);
schema = new Schema();
schema.populate(resultSet.getMetaData(), null);
ok = true;
} 
finally
{
if (!ok)
{
try
{
close();
}
catch (Exception ignored)
{
// ignore as another exception is already thrown
}
}
}

If anyone disagrees please state why

> 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 Fischer
> 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