diff options
author | 2018-07-17 13:05:22 +0900 | |
---|---|---|
committer | 2018-09-12 16:15:01 +0000 | |
commit | a203ce0d45caf8e103c3edaa4647268237d96306 (patch) | |
tree | 3ec53d2c1af928076c19fa9dd0fe99ac52b7509b /ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java | |
parent | b55ec83f6513a3e9fe22ea94e91d47af04296fdd (diff) |
sonar issue fix (updated readme)
Issue-ID: PORTAL-338
Change-Id: Ie338e4707271859bfcbc30dfd04585dba206fe6f
Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java')
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java index 28bd39d9..2e8875c0 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/HibernateConfiguration.java @@ -97,15 +97,9 @@ public class HibernateConfiguration { @SuppressWarnings("rawtypes") @Bean public Map dataSourceMap() throws Exception { - Connection conn = null; - Statement stmt = null; - ResultSet rs = null; - Map<String, ComboPooledDataSource> dataSourceMap = new HashMap<String, ComboPooledDataSource>(); - try { - conn = dataSource.getConnection(); - stmt = conn.createStatement(); - String sql = "SELECT schema_id,datasource_type,connection_url,user_name,password,driver_class,min_pool_size,max_pool_size,idle_connection_test_period FROM schema_info"; - rs = stmt.executeQuery(sql); + Map<String, ComboPooledDataSource> dataSourceMap = new HashMap<>(); + String sql = "SELECT schema_id,datasource_type,connection_url,user_name,password,driver_class,min_pool_size,max_pool_size,idle_connection_test_period FROM schema_info"; + try (Connection conn = dataSource.getConnection();Statement stmt = conn.createStatement();ResultSet rs = stmt.executeQuery(sql)){ while (rs.next()) { ComboPooledDataSource pool = new ComboPooledDataSource(); pool.setDriverClass(rs.getString("driver_class")); @@ -121,18 +115,7 @@ public class HibernateConfiguration { logger.error(EELFLoggerDelegate.errorLogger, "dataSourceMap failed", e); dataSourceMap = null; throw e; - } finally { - try { - if (rs != null) - rs.close(); - if (stmt != null) - stmt.close(); - if (conn != null) - conn.close(); - } catch (SQLException se2) { - logger.warn(EELFLoggerDelegate.errorLogger, "dataSourceMap failed to close", se2); - } - } + } return dataSourceMap; } |