DR AAF CADI integration
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / utils / DB.java
index 1952f94..8ca7118 100644 (file)
@@ -123,16 +123,14 @@ public class DB {
                             if (++n >= 3) {\r
                                 throw sqlEx;\r
                             }\r
-                        } finally {\r
-                            if (connection != null && !connection.isValid(1)) {\r
-                                connection.close();\r
-                                connection = null;\r
-                            }\r
                         }\r
                     } while (connection == null);\r
                 }\r
             }\r
-\r
+            if (connection != null && !connection.isValid(1)) {\r
+                connection.close();\r
+                connection = null;\r
+            }\r
         }\r
         return connection;\r
     }\r
@@ -187,8 +185,8 @@ public class DB {
             connection = getConnection();\r
             Set<String> actualTables = getTableSet(connection);\r
             boolean initialize = false;\r
-            for (String table : expectedTables) {\r
-                initialize |= !actualTables.contains(table.toLowerCase());\r
+            for (String tableName : expectedTables) {\r
+                initialize |= !actualTables.contains(tableName);\r
             }\r
             if (initialize) {\r
                 intlogger.info("PROV9001: First time startup; The database is being initialized.");\r
@@ -213,13 +211,13 @@ public class DB {
      * @return the set of table names\r
      */\r
     private Set<String> getTableSet(Connection connection) {\r
-        Set<String> tables = new HashSet<String>();\r
+        Set<String> tables = new HashSet<>();\r
         try {\r
             DatabaseMetaData md = connection.getMetaData();\r
             ResultSet rs = md.getTables(null, null, "%", null);\r
             if (rs != null) {\r
                 while (rs.next()) {\r
-                    tables.add(rs.getString("TABLE_NAME"));\r
+                    tables.add(rs.getString("TABLE_NAME").toUpperCase());\r
                 }\r
                 rs.close();\r
             }\r