From 57fb087114c59c0e5fdfea586f1e7b26f51dc530 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Thu, 6 Sep 2018 21:05:33 +0200 Subject: [PATCH] Unthrown Exception in main() --- .../de/hdm_stuttgart/sda1/insert/SimpleInsert.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/P/Sda1/Jdbc/Insert/MinimumTest/src/main/java/de/hdm_stuttgart/sda1/insert/SimpleInsert.java b/P/Sda1/Jdbc/Insert/MinimumTest/src/main/java/de/hdm_stuttgart/sda1/insert/SimpleInsert.java index 59157c9ac..d99407c2a 100644 --- a/P/Sda1/Jdbc/Insert/MinimumTest/src/main/java/de/hdm_stuttgart/sda1/insert/SimpleInsert.java +++ b/P/Sda1/Jdbc/Insert/MinimumTest/src/main/java/de/hdm_stuttgart/sda1/insert/SimpleInsert.java @@ -24,7 +24,7 @@ public class SimpleInsert { static private final Logger log = LogManager.getLogger (SimpleInsert.class); - static public final ResourceBundle jdbcProperties = ResourceBundle.getBundle("jdbc"); + static final ResourceBundle jdbcProperties = ResourceBundle.getBundle("jdbc"); /** * <p>Disclaimer:</p> @@ -48,16 +48,14 @@ public class SimpleInsert { * <li>... something forgotten to think about?</li> * </ul> */ - public static void main(String[] args) { + public static void main(String[] args) throws SQLException { - try (final Connection conn = DriverManager.getConnection( + final Connection conn = DriverManager.getConnection( jdbcProperties.getString("jdbcurl"), jdbcProperties.getString("username"), - jdbcProperties.getString("password"))) { + jdbcProperties.getString("password")); handleUserInput(conn.createStatement()); - } catch (final SQLException e) { - log.error("General database connection problem:", e); - } + conn.close(); } static private void handleUserInput(final Statement statement) throws SQLException { try (final Scanner scanner = new Scanner(System.in)) { -- GitLab