db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r382611 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java
Date Fri, 03 Mar 2006 01:44:07 GMT
Author: djd
Date: Thu Mar  2 17:44:06 2006
New Revision: 382611

URL: http://svn.apache.org/viewcvs?rev=382611&view=rev
Log:
DERBY-444 minor improvements to memory/ConnectionHandling code to
minimize object creation outside Derby.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java?rev=382611&r1=382610&r2=382611&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/ConnectionHandling.java
Thu Mar  2 17:44:06 2006
@@ -23,6 +23,7 @@
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Properties;
 
 /**
  * Test opening connections until a failure due to out of memory
@@ -44,12 +45,15 @@
         conn = null;
         
         ArrayList list = new ArrayList();
+        list.ensureCapacity(30000);
+        
+        Properties p = new Properties();
         
         while (true) {
             Connection c;
             try {
 
-                c = DriverManager.getConnection("jdbc:derby:wombat");
+                c = DriverManager.getConnection("jdbc:derby:wombat", p);
             } catch (SQLException e) {
                 if ("08004".equals(e.getSQLState()))
                     System.out.println("FIRST OOME: " + e.getSQLState() + " "
@@ -67,11 +71,11 @@
             }
             list.add(c);
             if ((list.size() % 1000) == 0) {
-                System.out.println(list.size() + " connections ...");
-                System.out.println("FREE " + Runtime.getRuntime().freeMemory());
+                System.out.print(".");
             }
         }
-
+        
+        System.out.println("");
         
         System.out.println(list.size() + " successful connections");
         
@@ -85,7 +89,7 @@
         for (int i = 0; i < 500; i++)
         {
             try {
-                  Connection c = DriverManager.getConnection("jdbc:derby:wombat");
+                  Connection c = DriverManager.getConnection("jdbc:derby:wombat", p);
                   list.add(c);
                   ok++;
             } catch (SQLException e) {
@@ -116,8 +120,8 @@
             list.set(i, null);
             if (c.isClosed())
                 alreadyClosed++;
-            
-            c.close();
+            else 
+                c.close();
         }
         System.out.println("already closed      : " + alreadyClosed);        
   }



Mime
View raw message