java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
branchv_0
changeset 101 97b0d9069133
parent 93 5a4dbe6f962c
child 104 245f1b88a3e6
--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Sun Dec 29 18:26:43 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Mon Dec 30 00:01:39 2013 +0100
@@ -66,20 +66,26 @@
 				case DATABASES:
 				case FORMATTERS:
 				case TYPES:
-					formatter = getFormatter();
-					formatter.writeStartBatch();
-					formatter.writeStartDatabase(new DatabaseDefinition());
+					try (Formatter f = getFormatter()) {
+						formatter = f;
+						formatter.writeStartBatch();
+						formatter.writeStartDatabase(new DatabaseDefinition());
+						showInfos(commands);
+						formatter.writeEndDatabase();
+						formatter.writeEndBatch();
+						formatter.close();
+					}
+					break;
+				default:
+					showInfos(commands);
 			}
 		}
+	}
 
+	private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {
 		for (InfoType infoType : commands) {
 			infoType.showInfo(this);
 		}
-
-		if (formatter != null) {
-			formatter.writeEndDatabase();
-			formatter.writeEndBatch();
-		}
 	}
 
 	private void listFormatters() throws ConfigurationException, FormatterException {