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


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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to