db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer ConnectionFactoryPooledImpl.java
Date Tue, 25 May 2004 15:02:01 GMT
arminw      2004/05/25 08:02:01

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ConnectionFactoryPooledImpl.java
  Log:
  add 'null' checks for rs and stmt
  
  Revision  Changes    Path
  1.14      +8 -7      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java
  
  Index: ConnectionFactoryPooledImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ConnectionFactoryPooledImpl.java	25 May 2004 11:17:45 -0000	1.13
  +++ ConnectionFactoryPooledImpl.java	25 May 2004 15:02:01 -0000	1.14
  @@ -173,6 +173,7 @@
           {
               Statement stmt = null;
               ResultSet rset = null;
  +            boolean isValid = false;
               if(failedValidationQuery > 100)
               {
                   throw new OJBRuntimeException("Validation of connection "+conn+" using
validation query "+
  @@ -185,14 +186,14 @@
                   if (rset.next())
                   {
                       failedValidationQuery = 0;
  -                    return true;
  +                    isValid = true;
                   }
                   else
                   {
                       ++failedValidationQuery;
                       log.warn("Validation query '" + query +
                               "' result set does not match, discard connection");
  -                    return false;
  +                    isValid = false;
                   }
               }
               catch (SQLException e)
  @@ -201,13 +202,12 @@
                   log.warn("Validation query for connection failed, discard connection. Query
was " +
                           query + ", Message was " + e.getMessage());
                   if (log.isDebugEnabled()) log.debug(e);
  -                return false;
               }
               finally
               {
                   try
                   {
  -                    rset.close();
  +                    if(rset != null) rset.close();
                   }
                   catch (SQLException t)
                   {
  @@ -215,13 +215,14 @@
                   }
                   try
                   {
  -                    stmt.close();
  +                    if(stmt != null) stmt.close();
                   }
                   catch (SQLException t)
                   {
                       if (log.isDebugEnabled()) log.debug("Statement already closed.", t);
                   }
               }
  +            return isValid;
           }
   
           public Object makeObject() throws Exception
  @@ -238,7 +239,7 @@
               {
                   ((Connection) obj).close();
               }
  -            catch (SQLException e)
  +            catch (SQLException ignore)
               {
                   //ignore it
               }
  
  
  

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


Mime
View raw message