private static void execWith(final Appender ap,
                                 final Properties config,
                                 final String[] args,
                                 final int argsOffset) throws Exception {

        logger.log(Level.FINER, "config = {0}", config);

        final File driverFile = new File(config.getProperty("jdbc.driverPath"));

        if (!driverFile.exists()) {
            throw new RuntimeException("JDBC driver not found: " + 
                                       driverFile.getAbsolutePath());

        } // end of if

        final Driver jdbcDriver = JDBC.loadDriver(driverFile.toURI().toURL());

        logger.log(Level.FINER, "jdbcDriver = {0}", jdbcDriver);

        if (jdbcDriver == null) {
            throw new RuntimeException("Cannot load JDBC driver: " + 
                                       driverFile.getAbsolutePath());

        } // end of if

        // ---

        final String jdbcUrl = config.getProperty("jdbc.url");
        final String user = config.getProperty("db.user");
        final String pass = args[argsOffset];
        final Formatting formatting = Formatting.forName(args[argsOffset+1]);
        final String sql = args[argsOffset+2];
        final Charset charset = Charset.
            forName(config.getProperty("db.charset"));
        final ArrayList<ColumnType> cols = new ArrayList<ColumnType>();

        for (int i = argsOffset+3; i < args.length; i++) {
            final ColumnType t = ColumnType.typeFor(args[i]);

            if (t == null) {
                throw new RuntimeException("Invalid column type: " + args[i]);
            } // end of if

            cols.add(t);
        } // end of for

        if (cols.isEmpty()) {
            throw new RuntimeException("No column descriptor");
        }  // end of if

        // ---

        final URLClassLoader cl = URLClassLoader.
            newInstance(new URL[] { driverFile.toURI().toURL() }, 
                        RowFormatter.class.getClassLoader());

        @SuppressWarnings("unchecked")
        final Class<RowFormatter> clazz = (Class<RowFormatter>) cl.
            loadClass("acolyte.RowFormatter");

        final RowFormatter fmt = clazz.
            getConstructor(Driver.class, String.class, String.class, 
                           String.class, String.class, Charset.class, 
                           Iterable.class, Formatting.class).
            newInstance(jdbcDriver, jdbcUrl, user, pass, 
                        sql, charset, cols, formatting);

        fmt.perform(ap);
    }
private static void execWith ( final Appender ap , final Properties config , final String [ ] args , final int argsOffset ) throws Exception { logger . log ( Level . FINER , "config = {0}" , config ) ; final File driverFile = new File ( config . getProperty ( "jdbc.driverPath" ) ) ; if ( ! driverFile . exists ( ) ) { throw new RuntimeException ( "JDBC driver not found: " + driverFile . getAbsolutePath ( ) ) ; } final Driver jdbcDriver = JDBC . loadDriver ( driverFile . toURI ( ) . toURL ( ) ) ; logger . log ( Level . FINER , "jdbcDriver = {0}" , jdbcDriver ) ; if ( jdbcDriver == null ) { throw new RuntimeException ( "Cannot load JDBC driver: " + driverFile . getAbsolutePath ( ) ) ; } final String jdbcUrl = config . getProperty ( "jdbc.url" ) ; final String user = config . getProperty ( "db.user" ) ; final String pass = args [ argsOffset ] ; final Formatting formatting = Formatting . forName ( args [ argsOffset + 1 ] ) ; final String sql = args [ argsOffset + 2 ] ; final Charset charset = Charset . forName ( config . getProperty ( "db.charset" ) ) ; final ArrayList < ColumnType > cols = new ArrayList < ColumnType > ( ) ; for ( int i = argsOffset + 3 ; i < args . length ; i ++ ) { final ColumnType t = ColumnType . typeFor ( args [ i ] ) ; if ( t == null ) { throw new RuntimeException ( "Invalid column type: " + args [ i ] ) ; } cols . add ( t ) ; } if ( cols . isEmpty ( ) ) { throw new RuntimeException ( "No column descriptor" ) ; } final URLClassLoader cl = URLClassLoader . newInstance ( new URL [ ] { driverFile . toURI ( ) . toURL ( ) } , RowFormatter . class . getClassLoader ( ) ) ; @ SuppressWarnings ( "unchecked" ) final Class < RowFormatter > clazz = ( Class < RowFormatter > ) cl . loadClass ( "acolyte.RowFormatter" ) ; final RowFormatter fmt = clazz . getConstructor ( Driver . class , String . class , String . class , String . class , String . class , Charset . class , Iterable . class , Formatting . class ) . newInstance ( jdbcDriver , jdbcUrl , user , pass , sql , charset , cols , formatting ) ; fmt . perform ( ap ) ; }
Executes