ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Butler <jeffgbut...@gmail.com>
Subject Re: Ibatis not closing prepared statements?
Date Tue, 14 Apr 2009 15:06:01 GMT
This may be related to iBATIS prepared statement caching.  Try turning
it off with this setting in your SqlMapConfig file:

<settings statementCachingEnabled="false"/>

Jeff Butler


On Tue, Apr 14, 2009 at 5:45 AM, Andrius Juozapaitis <andriusj@gmail.com> wrote:
> Hey,
>
> I've encountered an annoying error, ORA-01000 (too many open cursors)
> in our application. What we're doing is we're invoking a stored
> procedure, that returns a cursor, which is mapped to a domain object
> by a result map.
>
>    <procedure id="getRealEstateRegister2" parameterMap="myRegister2">
>        { ? = call NTR3_WEB.EPREKYBA_NTR.REGISTRAI_VAR_2CURS(?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }
>    </procedure>
>
> The parameter map is:
>
>
>    <parameterMap id="myRegister2" class="java.util.Map">
>        <parameter property="result" jdbcType="NUMERIC" mode="OUT" />
>        ....
>        <parameter property="list" javaType="java.sql.ResultSet"
> jdbcType="ORACLECURSOR" resultMap="register-entry-map" mode="OUT"/>
>        ....
>    </parameterMap>
>
>
> and the cursor is being mapped to a domain object by this map:
>
>    <resultMap id="register-entry-map" class="support.RealEstateRegisterEntry">
>        <result property="id" column="REG_ID"/>
>        <result property="systemRegistrationNr" column="REG_TARN_NR"/>
>        .....
>    </resultMap>
>
> It seems that ibatis is not closing the prepared statement in
> com.ibatis.sqlmap.engine.execution.SqlExecutor:514
> ...
>  private static void closeStatement(SessionScope sessionScope,
> PreparedStatement ps) {
>    if (ps != null) {
>      if (!sessionScope.hasPreparedStatement(ps)) {
>        try {
>          ps.close(); <<<< never gets here...
>        } catch (SQLException e) {
>          // ignore
>        }
>      }
>    }
>  }
>
>
> And oracle starts leaking cursors. Any idea how to solve this? What's
> the idea behind nto closing the statement if it's in session scope? On
> repeated executions the session scope doesn't contain that statement
> anyway? We are also using spring + jboss connection pooling, so
> closing the connection after the query is kinda out of question.
>
> best regards,
> Andrius Juozapaitis
>

Mime
View raw message