diff options
author | Parshad Patel <pars.patel@samsung.com> | 2018-11-08 14:32:49 +0900 |
---|---|---|
committer | Parshad Patel <pars.patel@samsung.com> | 2018-11-08 14:51:35 +0900 |
commit | e4c293eb36dd955685db390d114043569241a855 (patch) | |
tree | 22368b52348252d14cccb4b40173862cde7f088c /snmpmapper | |
parent | 3d0e5068a95eb32087531598036073ea9c0d48c5 (diff) |
Fix sonar issue in dcaegen2/services/mapper
Fix use try-with-resources sonar issue and remove printStackTrace
Issue-ID: DCAEGEN2-938
Change-Id: Ibbb6bb8bb9b099f33617368b3a4cbcf98032c983
Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'snmpmapper')
-rw-r--r-- | snmpmapper/src/main/java/org/onap/dcaegen2/services/mapper/snmpmapper/DAO/MappingFileDAOImpl.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/snmpmapper/src/main/java/org/onap/dcaegen2/services/mapper/snmpmapper/DAO/MappingFileDAOImpl.java b/snmpmapper/src/main/java/org/onap/dcaegen2/services/mapper/snmpmapper/DAO/MappingFileDAOImpl.java index 3d18d1d..6bfc269 100644 --- a/snmpmapper/src/main/java/org/onap/dcaegen2/services/mapper/snmpmapper/DAO/MappingFileDAOImpl.java +++ b/snmpmapper/src/main/java/org/onap/dcaegen2/services/mapper/snmpmapper/DAO/MappingFileDAOImpl.java @@ -59,7 +59,7 @@ public class MappingFileDAOImpl implements MappingFileDAO { LOGGER.info(entry.getKey() + ":" + entry.getValue()); } - if (env.containsKey("CONSUL_HOST") && env.containsKey("CONFIG_BINDING_SERVICE") && env.containsKey("HOSTNAME")) { + if (env.containsKey("CONSUL_HOST") && env.containsKey("CONFIG_BINDING_SERVICE") && env.containsKey("HOSTNAME")) { //TODO - Add logic to talk to Consul and CBS to get the configuration. For now, we will refer to configuration coming from docker env parameters LOGGER.info(">>>Dynamic configuration to be used"); @@ -88,10 +88,10 @@ public class MappingFileDAOImpl implements MappingFileDAO { - try (Connection con = DriverManager.getConnection(url, user, pwd)) { + try (Connection con = DriverManager.getConnection(url, user, pwd); + PreparedStatement pstmt = con.prepareStatement( + "INSERT INTO mapping_file(enterpriseid, mappingfilecontents, mimetype, File_Name) VALUES (?, ?, ?, ?)")) { LOGGER.debug("Connection established successfully"); - PreparedStatement pstmt = con.prepareStatement( - "INSERT INTO mapping_file(enterpriseid, mappingfilecontents, mimetype, File_Name) VALUES (?, ?, ?, ?)"); pstmt.setString(1, enterpriseid); pstmt.setBytes(2, mappingFile.getBytes()); @@ -102,7 +102,6 @@ public class MappingFileDAOImpl implements MappingFileDAO { }catch (Exception e) { LOGGER.error("Error occured due to :" + e.getMessage()); - e.printStackTrace(); } return "Uploaded successfully"; |