java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java
branchv_0
changeset 42 6fdaa4db3943
parent 36 025fbe816bbf
child 48 28735e71a1da
--- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java	Mon Dec 23 16:19:21 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java	Mon Dec 23 16:29:51 2013 +0100
@@ -109,9 +109,10 @@
 			if (fd == null) {
 				throw new ConfigurationException("Formatter is not configured: " + options.getFormatterName());
 			} else {
-				DatabaseConnection c = dd.connect();
-				Formatter f = fd.getInstance(new FormatterContext(options.getOutputStream()));
-				c.executeQuery(options.getSQLCommand(), f);
+				try (DatabaseConnection c = dd.connect()) {
+					Formatter f = fd.getInstance(new FormatterContext(options.getOutputStream()));
+					c.executeQuery(options.getSQLCommand(), f);
+				}
 			}
 		}
 	}