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