java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
author František Kučera <franta-hg@frantovo.cz>
Sat, 15 Aug 2015 09:40:22 +0200
branchv_0
changeset 203 504c4ba56d1c
parent 201 d3db5a72a089
child 209 8dfe037b3274
permissions -rw-r--r--
connection tunnelling: configuration and logging
     1 /**
     2  * SQL-DK
     3  * Copyright © 2013 František Kučera (frantovo.cz)
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, either version 3 of the License, or
     8  * (at your option) any later version.
     9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 package info.globalcode.sql.dk;
    19 
    20 import info.globalcode.sql.dk.configuration.CommandArgument;
    21 import info.globalcode.sql.dk.configuration.Configuration;
    22 import info.globalcode.sql.dk.configuration.ConfigurationException;
    23 import info.globalcode.sql.dk.configuration.ConfigurationProvider;
    24 import info.globalcode.sql.dk.configuration.DatabaseDefinition;
    25 import info.globalcode.sql.dk.configuration.FormatterDefinition;
    26 import info.globalcode.sql.dk.configuration.Properties;
    27 import info.globalcode.sql.dk.configuration.Property;
    28 import info.globalcode.sql.dk.configuration.TunnelDefinition;
    29 import info.globalcode.sql.dk.formatting.ColumnsHeader;
    30 import info.globalcode.sql.dk.formatting.FakeSqlArray;
    31 import info.globalcode.sql.dk.formatting.Formatter;
    32 import info.globalcode.sql.dk.formatting.FormatterContext;
    33 import info.globalcode.sql.dk.formatting.FormatterException;
    34 import java.io.BufferedReader;
    35 import java.io.ByteArrayOutputStream;
    36 import java.io.InputStreamReader;
    37 import java.io.PrintStream;
    38 import java.sql.Array;
    39 import java.sql.Driver;
    40 import java.sql.DriverManager;
    41 import java.sql.DriverPropertyInfo;
    42 import java.sql.SQLException;
    43 import java.util.ArrayList;
    44 import java.util.Collections;
    45 import java.util.Comparator;
    46 import java.util.EnumSet;
    47 import java.util.HashSet;
    48 import java.util.List;
    49 import java.util.Map.Entry;
    50 import java.util.ServiceLoader;
    51 import java.util.Set;
    52 import java.util.concurrent.ExecutorService;
    53 import java.util.concurrent.Executors;
    54 import java.util.concurrent.TimeUnit;
    55 import java.util.logging.Level;
    56 import java.util.logging.LogRecord;
    57 import java.util.logging.Logger;
    58 import javax.sql.rowset.RowSetMetaDataImpl;
    59 
    60 /**
    61  * Displays info like help, version etc.
    62  *
    63  * @author Ing. František Kučera (frantovo.cz)
    64  */
    65 public class InfoLister {
    66 
    67 	private static final Logger log = Logger.getLogger(InfoLister.class.getName());
    68 	/**
    69 	 * Fake database name for output formatting
    70 	 */
    71 	public static final String CONFIG_DB_NAME = "sqldk_configuration";
    72 	private final PrintStream out;
    73 	private final ConfigurationProvider configurationProvider;
    74 	private final CLIOptions options;
    75 	private Formatter formatter;
    76 
    77 	public InfoLister(PrintStream out, ConfigurationProvider configurationProvider, CLIOptions options) {
    78 		this.out = out;
    79 		this.configurationProvider = configurationProvider;
    80 		this.options = options;
    81 	}
    82 
    83 	public void showInfo() throws ConfigurationException, FormatterException {
    84 		EnumSet<InfoType> commands = options.getShowInfo();
    85 
    86 		boolean formattinNeeded = false;
    87 
    88 		for (InfoType infoType : commands) {
    89 			switch (infoType) {
    90 				case CONNECTION:
    91 				case JDBC_DRIVERS:
    92 				case JDBC_PROPERTIES:
    93 				case DATABASES:
    94 				case FORMATTERS:
    95 				case TYPES:
    96 				case JAVA_PROPERTIES:
    97 				case ENVIRONMENT_VARIABLES:
    98 					formattinNeeded = true;
    99 					break;
   100 			}
   101 		}
   102 
   103 		if (formattinNeeded) {
   104 			try (Formatter f = getFormatter()) {
   105 				formatter = f;
   106 				formatter.writeStartBatch();
   107 				DatabaseDefinition dd = new DatabaseDefinition();
   108 				dd.setName(CONFIG_DB_NAME);
   109 				formatter.writeStartDatabase(dd);
   110 				showInfos(commands);
   111 				formatter.writeEndDatabase();
   112 				formatter.writeEndBatch();
   113 				formatter.close();
   114 			}
   115 		} else {
   116 			showInfos(commands);
   117 		}
   118 	}
   119 
   120 	private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {
   121 		for (InfoType infoType : commands) {
   122 			infoType.showInfo(this);
   123 		}
   124 	}
   125 
   126 	private void listJavaProperties() throws FormatterException, ConfigurationException {
   127 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("value", SQLType.VARCHAR));
   128 		List<Object[]> data = new ArrayList<>();
   129 		for (Entry<Object, Object> e : System.getProperties().entrySet()) {
   130 			data.add(new Object[]{e.getKey(), e.getValue()});
   131 		}
   132 		printTable(formatter, header, "-- Java system properties", null, data, 0);
   133 	}
   134 
   135 	private void listEnvironmentVariables() throws FormatterException, ConfigurationException {
   136 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("value", SQLType.VARCHAR));
   137 		List<Object[]> data = new ArrayList<>();
   138 		for (Entry<String, String> e : System.getenv().entrySet()) {
   139 			data.add(new Object[]{e.getKey(), e.getValue()});
   140 		}
   141 		printTable(formatter, header, "-- environment variables", null, data, 0);
   142 	}
   143 
   144 	private void listFormatters() throws ConfigurationException, FormatterException {
   145 		ColumnsHeader header = constructHeader(
   146 				new HeaderField("name", SQLType.VARCHAR),
   147 				new HeaderField("built_in", SQLType.BOOLEAN),
   148 				new HeaderField("default", SQLType.BOOLEAN),
   149 				new HeaderField("class_name", SQLType.VARCHAR),
   150 				new HeaderField("valid", SQLType.BOOLEAN));
   151 		List<Object[]> data = new ArrayList<>();
   152 
   153 		String defaultFormatter = configurationProvider.getConfiguration().getDefaultFormatter();
   154 		defaultFormatter = defaultFormatter == null ? Configuration.DEFAULT_FORMATTER : defaultFormatter;
   155 
   156 		for (FormatterDefinition fd : configurationProvider.getConfiguration().getBuildInFormatters()) {
   157 			data.add(new Object[]{fd.getName(), true, defaultFormatter.equals(fd.getName()), fd.getClassName(), isInstantiable(fd)});
   158 		}
   159 
   160 		for (FormatterDefinition fd : configurationProvider.getConfiguration().getFormatters()) {
   161 			data.add(new Object[]{fd.getName(), false, defaultFormatter.equals(fd.getName()), fd.getClassName(), isInstantiable(fd)});
   162 		}
   163 
   164 		printTable(formatter, header, "-- configured and built-in output formatters", null, data);
   165 	}
   166 
   167 	private boolean isInstantiable(FormatterDefinition fd) {
   168 		try {
   169 			try (ByteArrayOutputStream testStream = new ByteArrayOutputStream()) {
   170 				fd.getInstance(new FormatterContext(testStream, new Properties(0)));
   171 				return true;
   172 			}
   173 		} catch (Exception e) {
   174 			log.log(Level.SEVERE, "Unable to create an instance of formatter: " + fd.getName(), e);
   175 			return false;
   176 		}
   177 	}
   178 
   179 	public void listTypes() throws FormatterException, ConfigurationException {
   180 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER));
   181 		List<Object[]> data = new ArrayList<>();
   182 		for (SQLType sqlType : SQLType.values()) {
   183 			data.add(new Object[]{sqlType.name(), sqlType.getCode()});
   184 		}
   185 		printTable(formatter, header, "-- data types", null, data);
   186 		log.log(Level.INFO, "Type names in --types option are case insensitive");
   187 	}
   188 
   189 	public void listDatabases() throws ConfigurationException, FormatterException {
   190 		ColumnsHeader header = constructHeader(
   191 				new HeaderField("database_name", SQLType.VARCHAR),
   192 				new HeaderField("user_name", SQLType.VARCHAR),
   193 				new HeaderField("database_url", SQLType.VARCHAR));
   194 		List<Object[]> data = new ArrayList<>();
   195 
   196 		final List<DatabaseDefinition> configuredDatabases = configurationProvider.getConfiguration().getDatabases();
   197 		if (configuredDatabases.isEmpty()) {
   198 			log.log(Level.WARNING, "No databases are configured.");
   199 		} else {
   200 			for (DatabaseDefinition dd : configuredDatabases) {
   201 				data.add(new Object[]{dd.getName(), dd.getUserName(), dd.getUrl()});
   202 
   203 				final TunnelDefinition tunnel = dd.getTunnel();
   204 				if (tunnel != null) {
   205 					log.log(Level.INFO, "Tunnel command: {0}", tunnel.getCommand());
   206 					for (CommandArgument ca : Functions.notNull(tunnel.getArguments())) {
   207 						log.log(Level.INFO, "\targument: {0}/{1}", new Object[]{ca.getType(), ca.getValue()});
   208 					}
   209 				}
   210 
   211 			}
   212 		}
   213 
   214 		printTable(formatter, header, "-- configured databases", null, data);
   215 	}
   216 
   217 	public void listJdbcDrivers() throws FormatterException, ConfigurationException {
   218 		ColumnsHeader header = constructHeader(
   219 				new HeaderField("class", SQLType.VARCHAR),
   220 				new HeaderField("version", SQLType.VARCHAR),
   221 				new HeaderField("major", SQLType.INTEGER),
   222 				new HeaderField("minor", SQLType.INTEGER),
   223 				new HeaderField("jdbc_compliant", SQLType.BOOLEAN));
   224 		List<Object[]> data = new ArrayList<>();
   225 
   226 		final ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
   227 		for (Driver d : drivers) {
   228 			data.add(new Object[]{
   229 				d.getClass().getName(),
   230 				d.getMajorVersion() + "." + d.getMinorVersion(),
   231 				d.getMajorVersion(),
   232 				d.getMinorVersion(),
   233 				d.jdbcCompliant()
   234 			});
   235 		}
   236 
   237 		printTable(formatter, header, "-- discovered JDBC drivers (available on the CLASSPATH)", null, data);
   238 	}
   239 
   240 	public void listJdbcProperties() throws FormatterException, ConfigurationException {
   241 		for (String dbName : options.getDatabaseNamesToListProperties()) {
   242 			ColumnsHeader header = constructHeader(
   243 					new HeaderField("property_name", SQLType.VARCHAR),
   244 					new HeaderField("required", SQLType.BOOLEAN),
   245 					new HeaderField("choices", SQLType.ARRAY),
   246 					new HeaderField("configured_value", SQLType.VARCHAR),
   247 					new HeaderField("description", SQLType.VARCHAR));
   248 			List<Object[]> data = new ArrayList<>();
   249 
   250 			DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName);
   251 
   252 			Driver driver = findDriver(dd);
   253 
   254 			if (driver == null) {
   255 				log.log(Level.WARNING, "No JDBC driver was found for DB: {0} with URL: {1}", new Object[]{dd.getName(), dd.getUrl()});
   256 			} else {
   257 				log.log(Level.INFO, "For DB: {0} was found JDBC driver: {1}", new Object[]{dd.getName(), driver.getClass().getName()});
   258 
   259 				try {
   260 					DriverPropertyInfo[] propertyInfos = driver.getPropertyInfo(dd.getUrl(), dd.getProperties().getJavaProperties());
   261 
   262 					Set<String> standardProperties = new HashSet<>();
   263 
   264 					for (DriverPropertyInfo pi : propertyInfos) {
   265 						Array choices = new FakeSqlArray(pi.choices, SQLType.VARCHAR);
   266 						data.add(new Object[]{
   267 							pi.name,
   268 							pi.required,
   269 							choices.getArray() == null ? "" : choices,
   270 							pi.value == null ? "" : pi.value,
   271 							pi.description
   272 						});
   273 						standardProperties.add(pi.name);
   274 					}
   275 
   276 					for (Property p : dd.getProperties()) {
   277 						if (!standardProperties.contains(p.getName())) {
   278 							data.add(new Object[]{
   279 								p.getName(),
   280 								"",
   281 								"",
   282 								p.getValue(),
   283 								""
   284 							});
   285 							log.log(Level.WARNING, "Your configuration contains property „{0}“ not declared by the JDBC driver.", p.getName());
   286 						}
   287 					}
   288 
   289 				} catch (SQLException e) {
   290 					log.log(Level.WARNING, "Error during getting property infos.", e);
   291 				}
   292 
   293 				List<Parameter> parameters = new ArrayList<>();
   294 				parameters.add(new NamedParameter("database", dbName, SQLType.VARCHAR));
   295 				parameters.add(new NamedParameter("driver_class", driver.getClass().getName(), SQLType.VARCHAR));
   296 				parameters.add(new NamedParameter("driver_major_version", driver.getMajorVersion(), SQLType.INTEGER));
   297 				parameters.add(new NamedParameter("driver_minor_version", driver.getMinorVersion(), SQLType.INTEGER));
   298 
   299 				printTable(formatter, header, "-- configured and configurable JDBC driver properties", parameters, data);
   300 			}
   301 		}
   302 
   303 	}
   304 
   305 	private Driver findDriver(DatabaseDefinition dd) {
   306 		final ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
   307 		for (Driver d : drivers) {
   308 			try {
   309 				if (d.acceptsURL(dd.getUrl())) {
   310 					return d;
   311 				}
   312 			} catch (SQLException e) {
   313 				log.log(Level.WARNING, "Error during finding JDBC driver for: " + dd.getName(), e);
   314 			}
   315 		}
   316 		return null;
   317 	}
   318 
   319 	/**
   320 	 * Parallelism for connection testing – maximum concurrent database connections.
   321 	 */
   322 	private static final int TESTING_THREAD_COUNT = 64;
   323 	/**
   324 	 * Time limit for all connection testing threads – particular timeouts per connection will be
   325 	 * much smaller.
   326 	 */
   327 	private static final long TESTING_AWAIT_LIMIT = 1;
   328 	private static final TimeUnit TESTING_AWAIT_UNIT = TimeUnit.DAYS;
   329 
   330 	public void testConnections() throws FormatterException, ConfigurationException {
   331 		ColumnsHeader header = constructHeader(
   332 				new HeaderField("database_name", SQLType.VARCHAR),
   333 				new HeaderField("configured", SQLType.BOOLEAN),
   334 				new HeaderField("connected", SQLType.BOOLEAN));
   335 
   336 		log.log(Level.FINE, "Testing DB connections in {0} threads", TESTING_THREAD_COUNT);
   337 
   338 		ExecutorService es = Executors.newFixedThreadPool(TESTING_THREAD_COUNT);
   339 
   340 		final Formatter currentFormatter = formatter;
   341 
   342 		printHeader(currentFormatter, header, "-- database configuration and connectivity test", null);
   343 
   344 		for (final String dbName : options.getDatabaseNamesToTest()) {
   345 			preloadDriver(dbName);
   346 		}
   347 
   348 		for (final String dbName : options.getDatabaseNamesToTest()) {
   349 			es.submit(new Runnable() {
   350 				// TODO: Java 8 – lambda
   351 				@Override
   352 				public void run() {
   353 					final Object[] row = testConnection(dbName);
   354 					synchronized (currentFormatter) {
   355 						printRow(currentFormatter, row);
   356 					}
   357 				}
   358 			});
   359 		}
   360 
   361 		es.shutdown();
   362 
   363 		try {
   364 			log.log(Level.FINEST, "Waiting for test results: {0} {1}", new Object[]{TESTING_AWAIT_LIMIT, TESTING_AWAIT_UNIT.name()});
   365 			boolean finished = es.awaitTermination(TESTING_AWAIT_LIMIT, TESTING_AWAIT_UNIT);
   366 			if (finished) {
   367 				log.log(Level.FINEST, "All testing threads finished in time limit.");
   368 			} else {
   369 				throw new FormatterException("Exceeded total time limit for test threads – this should never happen");
   370 			}
   371 		} catch (InterruptedException e) {
   372 			throw new FormatterException("Interrupted while waiting for test results", e);
   373 		}
   374 
   375 		printFooter(currentFormatter);
   376 	}
   377 
   378 	/**
   379 	 * JDBC driver classes should be preloaded in single thread to avoid deadlocks while doing
   380 	 * {@linkplain DriverManager#registerDriver(java.sql.Driver)} during parallel connections.
   381 	 *
   382 	 * @param dbName
   383 	 */
   384 	private void preloadDriver(String dbName) {
   385 		try {
   386 			DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName);
   387 			Driver driver = findDriver(dd);
   388 			if (driver == null) {
   389 				log.log(Level.WARNING, "No Driver found for DB: {0}", dbName);
   390 			} else {
   391 				log.log(Level.FINEST, "Driver preloading for DB: {0} was successfull", dbName);
   392 			}
   393 		} catch (Exception e) {
   394 			LogRecord r = new LogRecord(Level.WARNING, "Failed to preload the Driver for DB: {0}");
   395 			r.setParameters(new Object[]{dbName});
   396 			r.setThrown(e);
   397 			log.log(r);
   398 		}
   399 	}
   400 
   401 	public Object[] testConnection(String dbName) {
   402 		log.log(Level.FINE, "Testing connection to database: {0}", dbName);
   403 
   404 		boolean succesfullyConnected = false;
   405 		boolean succesfullyConfigured = false;
   406 
   407 		try {
   408 			DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName);
   409 			log.log(Level.FINE, "Database definition was loaded from configuration");
   410 			succesfullyConfigured = true;
   411 			try (DatabaseConnection dc = dd.connect(options.getDatabaseProperties())) {
   412 				succesfullyConnected = dc.test();
   413 			}
   414 			log.log(Level.FINE, "Database connection test was successful");
   415 		} catch (ConfigurationException | SQLException | RuntimeException e) {
   416 			log.log(Level.SEVERE, "Error during testing connection " + dbName, e);
   417 		}
   418 
   419 		return new Object[]{dbName, succesfullyConfigured, succesfullyConnected};
   420 	}
   421 
   422 	public void printResource(String fileName) {
   423 		try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(fileName)))) {
   424 			while (true) {
   425 				String line = reader.readLine();
   426 				if (line == null) {
   427 					break;
   428 				} else {
   429 					println(line);
   430 				}
   431 			}
   432 		} catch (Exception e) {
   433 			log.log(Level.SEVERE, "Unable to print this info. Please see our website for it: " + Constants.WEBSITE, e);
   434 		}
   435 	}
   436 
   437 	private void println(String line) {
   438 		out.println(line);
   439 	}
   440 
   441 	private void printTable(Formatter formatter, ColumnsHeader header, String sql, List<Parameter> parameters, List<Object[]> data) throws ConfigurationException, FormatterException {
   442 		printTable(formatter, header, sql, parameters, data, null);
   443 	}
   444 
   445 	private void printTable(Formatter formatter, ColumnsHeader header, String sql, List<Parameter> parameters, List<Object[]> data, final Integer sortByColumn) throws ConfigurationException, FormatterException {
   446 		printHeader(formatter, header, sql, parameters);
   447 
   448 		if (sortByColumn != null) {
   449 			Collections.sort(data, new Comparator<Object[]>() {
   450 
   451 				@Override
   452 				public int compare(Object[] o1, Object[] o2) {
   453 					String s1 = String.valueOf(o1[sortByColumn]);
   454 					String s2 = String.valueOf(o2[sortByColumn]);
   455 					return s1.compareTo(s2);
   456 				}
   457 			});
   458 		}
   459 
   460 		for (Object[] row : data) {
   461 			printRow(formatter, row);
   462 		}
   463 
   464 		printFooter(formatter);
   465 	}
   466 
   467 	private void printHeader(Formatter formatter, ColumnsHeader header, String sql, List<Parameter> parameters) {
   468 		formatter.writeStartStatement();
   469 		if (sql != null) {
   470 			formatter.writeQuery(sql);
   471 			if (parameters != null) {
   472 				formatter.writeParameters(parameters);
   473 			}
   474 		}
   475 		formatter.writeStartResultSet(header);
   476 	}
   477 
   478 	private void printRow(Formatter formatter, Object[] row) {
   479 		formatter.writeStartRow();
   480 		for (Object cell : row) {
   481 			formatter.writeColumnValue(cell);
   482 		}
   483 		formatter.writeEndRow();
   484 	}
   485 
   486 	private void printFooter(Formatter formatter) {
   487 		formatter.writeEndResultSet();
   488 		formatter.writeEndStatement();
   489 	}
   490 
   491 	private Formatter getFormatter() throws ConfigurationException, FormatterException {
   492 		String formatterName = options.getFormatterName();
   493 		formatterName = formatterName == null ? Configuration.DEFAULT_FORMATTER_PREFETCHING : formatterName;
   494 		FormatterDefinition fd = configurationProvider.getConfiguration().getFormatter(formatterName);
   495 		FormatterContext context = new FormatterContext(out, options.getFormatterProperties());
   496 		return fd.getInstance(context);
   497 	}
   498 
   499 	private ColumnsHeader constructHeader(HeaderField... fields) throws FormatterException {
   500 		try {
   501 			RowSetMetaDataImpl metaData = new RowSetMetaDataImpl();
   502 			metaData.setColumnCount(fields.length);
   503 
   504 			for (int i = 0; i < fields.length; i++) {
   505 				HeaderField hf = fields[i];
   506 				int sqlIndex = i + 1;
   507 				metaData.setColumnName(sqlIndex, hf.name);
   508 				metaData.setColumnLabel(sqlIndex, hf.name);
   509 				metaData.setColumnType(sqlIndex, hf.type.getCode());
   510 				metaData.setColumnTypeName(sqlIndex, hf.type.name());
   511 			}
   512 
   513 			return new ColumnsHeader(metaData);
   514 		} catch (SQLException e) {
   515 			throw new FormatterException("Error while constructing table headers", e);
   516 		}
   517 	}
   518 
   519 	private static class HeaderField {
   520 
   521 		String name;
   522 		SQLType type;
   523 
   524 		public HeaderField(String name, SQLType type) {
   525 			this.name = name;
   526 			this.type = type;
   527 		}
   528 	}
   529 
   530 	public enum InfoType {
   531 
   532 		HELP {
   533 					@Override
   534 					public void showInfo(InfoLister infoLister) {
   535 						infoLister.printResource(Constants.HELP_FILE);
   536 					}
   537 				},
   538 		VERSION {
   539 					@Override
   540 					public void showInfo(InfoLister infoLister) {
   541 						infoLister.printResource(Constants.VERSION_FILE);
   542 					}
   543 				},
   544 		LICENSE {
   545 					@Override
   546 					public void showInfo(InfoLister infoLister) {
   547 						infoLister.printResource(Constants.LICENSE_FILE);
   548 					}
   549 				},
   550 		JAVA_PROPERTIES {
   551 					@Override
   552 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   553 						infoLister.listJavaProperties();
   554 					}
   555 				},
   556 		ENVIRONMENT_VARIABLES {
   557 					@Override
   558 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   559 						infoLister.listEnvironmentVariables();
   560 					}
   561 				},
   562 		FORMATTERS {
   563 					@Override
   564 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   565 						infoLister.listFormatters();
   566 					}
   567 				},
   568 		TYPES {
   569 					@Override
   570 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   571 						infoLister.listTypes();
   572 					}
   573 				},
   574 		JDBC_DRIVERS {
   575 					@Override
   576 					public void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException {
   577 						infoLister.listJdbcDrivers();
   578 					}
   579 				},
   580 		JDBC_PROPERTIES {
   581 					@Override
   582 					public void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException {
   583 						infoLister.listJdbcProperties();
   584 					}
   585 				},
   586 		DATABASES {
   587 					@Override
   588 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   589 						infoLister.listDatabases();
   590 					}
   591 				},
   592 		CONNECTION {
   593 					@Override
   594 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   595 						infoLister.testConnections();
   596 					}
   597 				};
   598 
   599 		public abstract void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException;
   600 	}
   601 }