Hi,

I have a proposed correction for the class PoolableConnectionFactory.java

The method  validateObject(Object object) has a block of code that 
responsible for doing the test-query that currently looks like this:

             if(null != query) {
                 Statement stmt = null;
                 ResultSet rset = null;
                 try {
                     long startTime = System.currentTimeMillis();
                     stmt = conn.createStatement();
                     rset = stmt.executeQuery(query);
                     if(rset.next()) {
                       System.err.println("val took: " + 
(System.currentTimeMillis() - startTime));
                         return true;
                     } else {
                         return false;
                     }
                 } catch(Exception e) {
                     try {
                         rset.close();
                     } catch(Throwable t) {
                         ;
                     }
                     try {
                         stmt.close();
                     } catch(Throwable t) {
                         ;
                     }
                     return false;
                 }
             } else {

I propose fixing the try-catch block that does the test query so that it 
looks like this:

             if(null != query) {
                 Statement stmt = null;
                 ResultSet rset = null;
                 try {
                     long startTime = System.currentTimeMillis();
                     stmt = conn.createStatement();
                     rset = stmt.executeQuery(query);
                     if(rset.next()) {
                       System.err.println("val took: " + 
(System.currentTimeMillis() - startTime));
                         return true;
                     } else {
                         return false;
                     }
                 } catch(Exception e) {
                     return false;
                 } finally {
                     try {
                         rset.close();
                     } catch(Throwable t) {
                         ;
                     }
                     try {
                         stmt.close();
                     } catch(Throwable t) {
                         ;
                     }
                 }
             } else {

In case you missed it, I am proposing moving the closing of the result set 
and statement to a "finally" block.

This is important to me because RDBMs only allow a limited number of 
statements/result sets per connection, the current code relies on garbage 
collection to close them, but this might not happen until after the 
connection has already been re-borrowed several more times.  Oracle 8.1x 
especially has a problem with connections becoming corrupt if statements 
are closed meticulously.

Comments/Thoughts?

James


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to