You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Henri Yandell (JIRA)" <ji...@apache.org> on 2006/05/17 08:11:09 UTC

[jira] Updated: (DBCP-81) [dbcp] NPE in PoolableConnectionFactory validating the connection with an invalid SQL statement

     [ http://issues.apache.org/jira/browse/DBCP-81?page=all ]

Henri Yandell updated DBCP-81:
------------------------------

    Reporter: Joerg Schaible  (was: Jörg Schaible)

> [dbcp] NPE in PoolableConnectionFactory validating the connection with an invalid SQL statement
> -----------------------------------------------------------------------------------------------
>
>          Key: DBCP-81
>          URL: http://issues.apache.org/jira/browse/DBCP-81
>      Project: Commons Dbcp
>         Type: Bug

>     Versions: 1.2 Final
>  Environment: Operating System: All
> Platform: All
>     Reporter: Joerg Schaible
>     Priority: Critical

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

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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