protected void loadDriver(String className, Optional<String> driverPath) addDriverJarToClasspath(driverPath.get()); } else { try { File root = findPluginRoot(); File driverLib = new File(root, "default_jdbc_driver"); File[] files = driverLib.listFiles(new FileFilter() { for (File file : files) { logger.info("JDBC Driver = " + file.getAbsolutePath()); addDriverJarToClasspath(file.getAbsolutePath());
@Override public ConfigDiff resume(TaskSource taskSource, Schema schema, int taskCount, InputPlugin.Control control) { PluginTask task = taskSource.loadTask(getTaskClass()); // TODO when parallel execution is implemented and enabled, (maybe) order_by // is necessary to resume. transaction() gets the range of order_by // colum and set it to WHERE condition to make the operation deterministic return buildNextConfigDiff(task, control.run(taskSource, schema, taskCount)); }
private List<ColumnGetter> newColumnGetters(JdbcInputConnection con, PluginTask task, JdbcSchema querySchema, PageBuilder pageBuilder) throws SQLException { ColumnGetterFactory factory = newColumnGetterFactory(pageBuilder, task.getDefaultTimeZone()); ImmutableList.Builder<ColumnGetter> getters = ImmutableList.builder(); for (JdbcColumn c : querySchema.getColumns()) { JdbcColumnOption columnOption = columnOptionOf(task.getColumnOptions(), task.getDefaultColumnOptions(), c, factory.getJdbcType(c.getSqlType())); getters.add(factory.newColumnGetter(con, task, c, columnOption)); } return getters.build(); }
protected Schema setupTask(JdbcInputConnection con, PluginTask task) throws SQLException String actualTableName = normalizeTableNameCase(con, task.getTable().get()); task.setTable(Optional.of(actualTableName)); String rawQuery = getRawQuery(task, con); List<Integer> incrementalColumnIndexes = findIncrementalColumnIndexes(querySchema, incrementalColumns); task.setIncrementalColumnIndexes(incrementalColumnIndexes); newColumnGetters(con, task, querySchema, null); ColumnGetterFactory factory = newColumnGetterFactory(null, task.getDefaultTimeZone()); ImmutableList.Builder<Column> columns = ImmutableList.builder(); for (int i = 0; i < querySchema.getCount(); i++) { JdbcColumn column = querySchema.getColumn(i); JdbcColumnOption columnOption = columnOptionOf(task.getColumnOptions(), task.getDefaultColumnOptions(), column, factory.getJdbcType(column.getSqlType())); columns.add(new Column(i, column.getName(),
@Override public ConfigDiff transaction(ConfigSource config, InputPlugin.Control control) { PluginTask task = config.loadConfig(getTaskClass()); if (task.getIncremental()) { if (task.getOrderBy().isPresent()) { throw new ConfigException("order_by option must not be set if incremental is true"); } } else { if (!task.getIncrementalColumns().isEmpty()) { throw new ConfigException("'incremental: true' must be set if incremental_columns is set"); } } Schema schema; try (JdbcInputConnection con = newConnection(task)) { con.showDriverVersion(); // TODO incremental_columns is not set => get primary key schema = setupTask(con, task); } catch (SQLException ex) { throw Throwables.propagate(ex); } return buildNextConfigDiff(task, control.run(task.dump(), schema, 1)); }
PageOutput output) PluginTask task = taskSource.loadTask(getTaskClass()); try (JdbcInputConnection con = newConnection(task)) { List<ColumnGetter> getters = newColumnGetters(con, task, querySchema, pageBuilder); try (BatchSelect cursor = con.newSelectCursor(builtQuery, getters, task.getFetchRows(), task.getSocketTimeout())) { while (true) { long rows = fetch(cursor, getters, pageBuilder); if (rows <= 0L) { break;