You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by "Chad Schoettger (JIRA)" <ji...@apache.org> on 2007/07/10 23:45:04 UTC

[jira] Resolved: (BEEHIVE-1201) Use of JDBC control setConnection() method may cause prepared statements to remain open

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

Chad Schoettger resolved BEEHIVE-1201.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: V.Next
         Assignee: matt c  (was: Chad Schoettger)

Fixed, svn rev 555078, applied patch to release prepared statements when setConnection() api is used.

> Use of JDBC control setConnection() method may cause prepared statements to remain open
> ---------------------------------------------------------------------------------------
>
>                 Key: BEEHIVE-1201
>                 URL: https://issues.apache.org/jira/browse/BEEHIVE-1201
>             Project: Beehive
>          Issue Type: Bug
>          Components: System Controls
>            Reporter: Chad Schoettger
>            Assignee: matt c
>             Fix For: V.Next
>
>
> When setConnection(con) is used, the prepared statements created by the JdbcControl, are not closed as part of the onRelease event.
> Eventually my connection pool becomes exhausted as the connections aren't closed completely. (SLEEPING)
> I altered the JdbcControl to close these prepared statements and my connections are released.
> Specifically I moved the code
>      if (_connection != null && !_externalConnection) {
>            }
> From the onRelease() method to the cleanupConnection() method to allow the PreparedStatements to be closed.
> IE
>    private void cleanupConnection() {
>        for (PreparedStatement ps : getResources()) {
>            try {
>                ps.close();
>            }
>            catch (SQLException sqe) {
>                // noop
>            }
>        }
>        getResources().clear();
>        if (_connection != null && !_externalConnection) {
> /*************************** Code Inserted
> ***************************************/
>           try {
>                  _connection.close();
>            }
>            catch (SQLException e) {
>                  throw new ControlException("SQL Exception while
> attempting to close database connection.", e);
>            }
>        _connection = null;
>        _externalConnection = false;
>        }
>    }
> Environment
> Beehive 1.0.2
> Tomcat 5.5.20
> Apache commons connection pool
> (org.apache.commons.dbcp.BasicDataSourceFactory)
> JTDS open source driver (net.sourceforge.jtds.jdbc.Driver)
> SQL Server 2005

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