1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sat Jan 11 18:37:57 2014 +0100
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Wed Jan 15 18:15:55 2014 +0100
1.3 @@ -125,6 +125,9 @@
1.4 case Tokens.INFO_VERSION:
1.5 options.addShowInfo(InfoType.VERSION);
1.6 break;
1.7 + case Tokens.INFO_JDBC_DRIVERS:
1.8 + options.addShowInfo(InfoType.JDBC_DRIVERS);
1.9 + break;
1.10 case Tokens.INFO_DATABASES:
1.11 options.addShowInfo(InfoType.DATABASES);
1.12 break;
1.13 @@ -166,6 +169,7 @@
1.14 public static final String INFO_LICENSE = "--license"; // bash-completion:option // help: print license
1.15 public static final String INFO_FORMATTERS = "--list-formatters"; // bash-completion:option // help: print list of available formatters
1.16 public static final String INFO_TYPES = "--list-types"; // bash-completion:option // help: print list of available data types
1.17 + public static final String INFO_JDBC_DRIVERS = "--list-jdbc-drivers"; // bash-completion:option // help: list of available JDBC drivers
1.18 public static final String INFO_DATABASES = "--list-databases"; // bash-completion:option // help: print list of configured databases
1.19 public static final String INFO_CONNECTION = "--test-connection"; // bash-completion:option // help: test connection to particular database
1.20
2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Jan 11 18:37:57 2014 +0100
2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Wed Jan 15 18:15:55 2014 +0100
2.3 @@ -29,10 +29,12 @@
2.4 import java.io.BufferedReader;
2.5 import java.io.InputStreamReader;
2.6 import java.io.PrintStream;
2.7 +import java.sql.Driver;
2.8 import java.sql.SQLException;
2.9 import java.util.ArrayList;
2.10 import java.util.EnumSet;
2.11 import java.util.List;
2.12 +import java.util.ServiceLoader;
2.13 import java.util.logging.Level;
2.14 import java.util.logging.Logger;
2.15 import javax.sql.rowset.RowSetMetaDataImpl;
2.16 @@ -64,6 +66,7 @@
2.17 for (InfoType infoType : commands) {
2.18 switch (infoType) {
2.19 case CONNECTION:
2.20 + case JDBC_DRIVERS:
2.21 case DATABASES:
2.22 case FORMATTERS:
2.23 case TYPES:
2.24 @@ -148,6 +151,29 @@
2.25 printTable(formatter, header, data);
2.26 }
2.27
2.28 + public void listJdbcDrivers() throws FormatterException, ConfigurationException {
2.29 + ColumnsHeader header = constructHeader(
2.30 + new HeaderField("class", SQLType.VARCHAR),
2.31 + new HeaderField("version", SQLType.VARCHAR),
2.32 + new HeaderField("major", SQLType.INTEGER),
2.33 + new HeaderField("minor", SQLType.INTEGER),
2.34 + new HeaderField("jdbc_compliant", SQLType.BOOLEAN));
2.35 + List<Object[]> data = new ArrayList<>();
2.36 +
2.37 + final ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
2.38 + for (Driver d : drivers) {
2.39 + data.add(new Object[]{
2.40 + d.getClass().getName(),
2.41 + d.getMajorVersion() + "." + d.getMinorVersion(),
2.42 + d.getMajorVersion(),
2.43 + d.getMinorVersion(),
2.44 + d.jdbcCompliant()});
2.45 + }
2.46 +
2.47 + printTable(formatter, header, data);
2.48 +
2.49 + }
2.50 +
2.51 public void testConnection() throws FormatterException, ConfigurationException {
2.52 ColumnsHeader header = constructHeader(
2.53 new HeaderField("database_name", SQLType.VARCHAR),
2.54 @@ -287,6 +313,12 @@
2.55 infoLister.listTypes();
2.56 }
2.57 },
2.58 + JDBC_DRIVERS {
2.59 + @Override
2.60 + public void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException {
2.61 + infoLister.listJdbcDrivers();
2.62 + }
2.63 + },
2.64 DATABASES {
2.65 @Override
2.66 public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {