Index: org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java,v
retrieving revision 1.15
diff -u -r1.15 ConnectionPoolTest.java
--- org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java	11 Jan 2005 08:25:48 -0000	1.15
+++ org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java	22 Jul 2007 07:56:10 -0000
@@ -14,6 +14,7 @@
 import org.postgresql.test.TestUtil;
 import javax.sql.*;
 import java.sql.*;
+import java.util.*;
 import java.io.*;
 
 /**
@@ -25,6 +26,8 @@
  */
 public class ConnectionPoolTest extends BaseDataSourceTest
 {
+    private ArrayList connections = new ArrayList();
+    
     /**
      * Constructor required by JUnit
      */
@@ -48,6 +51,19 @@
             bds.setPassword(TestUtil.getPassword());
         }
     }
+    
+    protected void tearDown() throws Exception
+    {
+        for (Iterator i = connections.iterator(); i.hasNext(); ) {
+            PooledConnection c = (PooledConnection) i.next();
+            try {
+                c.close();
+            } catch (Exception ex) {
+                // close throws nullptr or other evil things if the connection
+                // is already closed
+            }
+        }
+    }
 
     /**
      * Though the normal client interface is to grab a Connection, in
@@ -61,7 +77,9 @@
         // jdbc.optional.ConnectionPool because our ObjectFactory
         // returns only the top level class, not the specific
         // jdbc2/jdbc3 implementations.
-        return ((PGConnectionPoolDataSource)bds).getPooledConnection();
+        PooledConnection c = ((PGConnectionPoolDataSource)bds).getPooledConnection();
+        connections.add(c);
+        return c; 
     }
 
     /**
