PHOENIX-2063 Addendum patch to fix connection usage

Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/997de5e6
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/997de5e6
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/997de5e6

Branch: refs/heads/calcite
Commit: 997de5e6cab988018e723ed29a53da1bae61def4
Parents: 3b1bfa0
Author: James Taylor <[email protected]>
Authored: Thu Jul 9 22:55:25 2015 -0700
Committer: James Taylor <[email protected]>
Committed: Thu Jul 9 22:55:25 2015 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/RowValueConstructorIT.java  | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/997de5e6/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
index 0cf5455..b9e50a4 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
@@ -1426,10 +1426,11 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
 
     @Test
     public void testCountDistinct1() throws Exception {
-        Connection conn = DriverManager.getConnection(getUrl());
+        Connection conn = nextConnection(getUrl());
         String ddl = "CREATE TABLE regions1 (region_name VARCHAR PRIMARY KEY, 
a INTEGER, b INTEGER)";
         conn.createStatement().execute(ddl);
-        conn.commit();
+        
+        conn = nextConnection(getUrl());
         PreparedStatement stmt = conn.prepareStatement("UPSERT INTO 
regions1(region_name, a, b) VALUES('a', 6,3)");
         stmt.execute();
         stmt = conn.prepareStatement("UPSERT INTO regions1(region_name, a, b) 
VALUES('b', 2,4)");
@@ -1437,18 +1438,23 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
         stmt = conn.prepareStatement("UPSERT INTO regions1(region_name, a, b) 
VALUES('c', 6,3)");
         stmt.execute();
         conn.commit();
+
+        conn = nextConnection(getUrl());
         ResultSet rs;
         rs = conn.createStatement().executeQuery("SELECT COUNT(DISTINCT (a,b)) 
from regions1");
         assertTrue(rs.next());
         assertEquals(2, rs.getInt(1));
+        conn.close();
     }
 
     @Test
     public void testCountDistinct2() throws Exception {
-        Connection conn = DriverManager.getConnection(getUrl());
+        Connection conn = nextConnection(getUrl());
         String ddl = "CREATE TABLE regions2 (region_name VARCHAR PRIMARY KEY, 
a VARCHAR, b VARCHAR)";
         conn.createStatement().execute(ddl);
         conn.commit();
+        
+        conn = nextConnection(getUrl());
         PreparedStatement stmt = conn.prepareStatement("UPSERT INTO 
regions2(region_name, a, b) VALUES('a', 'fooo','abc')");
         stmt.execute();
         stmt = conn.prepareStatement("UPSERT INTO regions2(region_name, a, b) 
VALUES('b', 'off','bac')");
@@ -1456,6 +1462,8 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
         stmt = conn.prepareStatement("UPSERT INTO regions2(region_name, a, b) 
VALUES('c', 'fooo', 'abc')");
         stmt.execute();
         conn.commit();
+
+        conn = nextConnection(getUrl());
         ResultSet rs;
         rs = conn.createStatement().executeQuery("SELECT COUNT(DISTINCT (a,b)) 
from regions2");
         assertTrue(rs.next());
@@ -1464,10 +1472,11 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
 
     @Test
     public void testCountDistinct3() throws Exception {
-        Connection conn = DriverManager.getConnection(getUrl());
+        Connection conn = nextConnection(getUrl());
         String ddl = "CREATE TABLE regions3 (region_name VARCHAR PRIMARY KEY, 
a Boolean, b Boolean)";
         conn.createStatement().execute(ddl);
-        conn.commit();
+        
+        conn = nextConnection(getUrl());
         PreparedStatement stmt = conn.prepareStatement("UPSERT INTO 
regions3(region_name, a, b) VALUES('a', true, true)");
         stmt.execute();
         stmt = conn.prepareStatement("UPSERT INTO regions3(region_name, a, b) 
VALUES('b', true, False)");
@@ -1477,6 +1486,8 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
         stmt = conn.prepareStatement("UPSERT INTO regions3(region_name, a, b) 
VALUES('d', true, false)");
         stmt.execute();
         conn.commit();
+
+        conn = nextConnection(getUrl());
         ResultSet rs;
         rs = conn.createStatement().executeQuery("SELECT COUNT(DISTINCT (a,b)) 
from regions3");
         assertTrue(rs.next());
@@ -1485,10 +1496,11 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
 
     @Test
     public void testCountDistinct4() throws Exception {
-        Connection conn = DriverManager.getConnection(getUrl());
+        Connection conn = nextConnection(getUrl());
         String ddl = "CREATE TABLE regions4 (region_name VARCHAR PRIMARY KEY, 
a VARCHAR, b VARCHAR)";
         conn.createStatement().execute(ddl);
-        conn.commit();
+        
+        conn = nextConnection(getUrl());
         PreparedStatement stmt = conn.prepareStatement("UPSERT INTO 
regions4(region_name, a, b) VALUES('a', 'fooo','abc')");
         stmt.execute();
         stmt = conn.prepareStatement("UPSERT INTO regions4(region_name, a, b) 
VALUES('b', 'off','bac')");
@@ -1496,6 +1508,8 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
         stmt = conn.prepareStatement("UPSERT INTO regions4(region_name, a, b) 
VALUES('c', 'foo', 'abc')");
         stmt.execute();
         conn.commit();
+        
+        conn = nextConnection(getUrl());
         ResultSet rs;
         rs = conn.createStatement().executeQuery("SELECT COUNT(DISTINCT (a,b)) 
from regions4");
         assertTrue(rs.next());

Reply via email to