diff options
author | Ryan D. Brooks | 2016-04-21 13:23:13 -0400 |
---|---|---|
committer | Angel Avila | 2016-04-21 13:23:13 -0400 |
commit | ee98c5442130c551f55899f183b7770f870c9a06 (patch) | |
tree | c8f183e71e5b2e5238e8a9384461c4cc0a66881a /plugins/org.eclipse.osee.orcs.db.test | |
parent | cb879478a3ea400494308e482478b813bed59f64 (diff) | |
download | org.eclipse.osee-ee98c5442130c551f55899f183b7770f870c9a06.tar.gz org.eclipse.osee-ee98c5442130c551f55899f183b7770f870c9a06.tar.xz org.eclipse.osee-ee98c5442130c551f55899f183b7770f870c9a06.zip |
refactor: Remove usage of JdbcClient.getStatement
Change-Id: Iaddb5f6bb88bf7c03e114f5a5289311c7acac935
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db.test')
-rw-r--r-- | plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java index d9612a2c20..3449192bce 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java @@ -40,7 +40,6 @@ public class PurgeAttributeTest { @Test public void testPurgeAttribute() throws Exception { JdbcClient jdbcClient = jdbcService.getClient(); - JdbcStatement stmt = jdbcClient.getStatement(); int prePurgeAttributeCount = getCount(jdbcClient, "osee_attribute"); int preAttributeRows = getCount(jdbcClient, "osee_attribute where value = 'Software Requirements'"); @@ -49,11 +48,9 @@ public class PurgeAttributeTest { int prePurgeTxsCount = getCount(jdbcClient, "osee_txs"); - stmt.runPreparedQuery("select attr_id from osee_attribute where value = 'Software Requirements'"); List<Long> toPurge = new LinkedList<>(); - while (stmt.next()) { - toPurge.add(stmt.getLong("attr_id")); - } + jdbcClient.runQuery(stmt -> toPurge.add(stmt.getLong("attr_id")), + "select attr_id from osee_attribute where value = 'Software Requirements'"); PurgeAttributesDatabaseTxCallable callable = new PurgeAttributesDatabaseTxCallable(null, null, jdbcClient, sqlJoinFactory, toPurge, null); @@ -71,11 +68,12 @@ public class PurgeAttributeTest { } private int getCount(JdbcClient jdbcClient, String table) { - JdbcStatement stmt = jdbcClient.getStatement(); int toReturn = -1; - stmt.runPreparedQuery("select count(1) from " + table); - while (stmt.next()) { - toReturn = stmt.getInt(1); + try (JdbcStatement chStmt = jdbcClient.getStatement()) { + chStmt.runPreparedQuery("select count(1) from " + table); + while (chStmt.next()) { + toReturn = chStmt.getInt(1); + } } return toReturn; } |