You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/09/16 16:03:34 UTC

DO NOT REPLY [Bug 36685] New: - [DBCP 1.2.1] NPE in PoolableConnectionFactory validating the connection with an invalid SQL statement

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36685>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36685

           Summary: [DBCP 1.2.1] NPE in PoolableConnectionFactory validating
                    the connection with an invalid SQL statement
           Product: Commons
           Version: 1.2 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Dbcp
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: joerg.schaible@gmx.de


The PooleableConnectionFactory.validateConnection(Connection) throws a NPE, if
the provided SQL statement for validation is invalid itself (e.g. uses a
non-existing table). See the code snippet below. If stmt.executeQuery(query)
throws an SQLException, rset is still null, but will be closed in the finally
block ==> NPE!


        if(null != query) {
            Statement stmt = null;
            ResultSet rset = null;
            try {
                stmt = conn.createStatement();
                rset = stmt.executeQuery(query);
                if(!rset.next()) {
                    throw new SQLException("validationQuery didn't return a row");
                }
            } finally {
                try {
                    rset.close();
                } catch(Exception t) {
                    // ignored
                }
                try {
                    stmt.close();
                } catch(Exception t) {
                    // ignored
                }

            }
        }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org