Fix try-with-resources 55/68055/1
authorArindam Mondal <arind.mondal@samsung.com>
Thu, 20 Sep 2018 10:51:53 +0000 (19:51 +0900)
committerarind.mondal <arind.mondal@samsung.com>
Thu, 20 Sep 2018 11:02:02 +0000 (20:02 +0900)
Issue-ID: DCAEGEN2-818

Change-Id: I7d8afc8bb78c9534671602ed37db7f6d14f5de81
Signed-off-by: arind.mondal <arind.mondal@samsung.com>
UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VESAdapterInitializer.java

index ca1bcc9..b63eb1e 100644 (file)
@@ -147,10 +147,9 @@ public class VESAdapterInitializer implements CommandLineRunner, Ordered {
        }
 
        public void fetchMappingFile() {
-               try (Connection con = DriverManager.getConnection(dBurl, user, pwd)) {
+               String query = "SELECT * FROM mapping_file";
+               try (Connection con = DriverManager.getConnection(dBurl, user, pwd);PreparedStatement pstmt = con.prepareStatement(query);ResultSet rs = pstmt.executeQuery();) {
                        LOGGER.info("Retrieving data from DB");
-                       PreparedStatement pstmt = con.prepareStatement("SELECT * FROM mapping_file");
-                       ResultSet rs = pstmt.executeQuery();
                        // parsing the column each time is a linear search
                        int column1Pos = rs.findColumn("enterpriseid");
                        int column2Pos = rs.findColumn("mappingfilecontents");