@Test public void createDrainForDrain() throws Exception { Map<String, String> conf = new HashMap<>(); conf.put(JdbcProcess.TABLE.key(), "PAIR"); conf.put(JdbcProcess.COLUMNS.key(), "KEY,VALUE"); conf.put(JdbcProcess.JDBC_SUPPORT.key(), PairSupport.class.getName()); conf.put(JdbcProcess.CUSTOM_TRUNCATE.key(), "DELETE FROM PAIR"); conf.put(JdbcProcess.OPERATION.key(), JdbcProcess.OperationKind.INSERT_AFTER_TRUNCATE.value()); h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (1, 'Hello1, world!')"); ProcessScript<Pair> process = process(dummy(), new DriverScript("jdbc", conf)); JdbcResourceManipulator manipulator = new JdbcResourceManipulator(profile(), new ParameterList()); try (DrainDriver<Pair> driver = manipulator.createDrainForDrain(process)) { driver.prepare(); driver.put(new Pair(2, "Hello2, world!")); driver.put(new Pair(3, "Hello3, world!")); } test("Hello1, world!", "Hello2, world!", "Hello3, world!"); }
@Override public <T> DrainDriver<T> createDrainForDrain(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.DRAIN); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcDrainDriver<T> result = new JdbcDrainDriver<>(profile, jdbc, conn, false); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForDrain(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.DRAIN); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcDrainDriver<T> result = new JdbcDrainDriver<>(profile, jdbc, conn, false); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForDrain(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.DRAIN); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcDrainDriver<T> result = new JdbcDrainDriver<>(profile, jdbc, conn, false); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } JdbcResourceManipulator(JdbcProfile profile, ParameterList arguments); }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForDrain(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.DRAIN); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcDrainDriver<T> result = new JdbcDrainDriver<>(profile, jdbc, conn, false); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } JdbcResourceManipulator(JdbcProfile profile, ParameterList arguments); @Override String getName(); @Override void cleanupSource(ProcessScript<?> script); @Override void cleanupDrain(ProcessScript<?> script); @Override SourceDriver<T> createSourceForSource(ProcessScript<T> script); @Override DrainDriver<T> createDrainForSource(ProcessScript<T> script); @Override SourceDriver<T> createSourceForDrain(ProcessScript<T> script); @Override DrainDriver<T> createDrainForDrain(ProcessScript<T> script); }
JdbcResourceManipulator extends ResourceManipulator { @Override public <T> DrainDriver<T> createDrainForDrain(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } JdbcScript<T> jdbc = JdbcResourceUtil.convert(profile, script, arguments, DriverScript.Kind.DRAIN); boolean succeed = false; Connection conn = profile.openConnection(); try { JdbcDrainDriver<T> result = new JdbcDrainDriver<>(profile, jdbc, conn, false); succeed = true; return result; } finally { if (succeed == false) { close(conn); } } } JdbcResourceManipulator(JdbcProfile profile, ParameterList arguments); @Override String getName(); @Override void cleanupSource(ProcessScript<?> script); @Override void cleanupDrain(ProcessScript<?> script); @Override SourceDriver<T> createSourceForSource(ProcessScript<T> script); @Override DrainDriver<T> createDrainForSource(ProcessScript<T> script); @Override SourceDriver<T> createSourceForDrain(ProcessScript<T> script); @Override DrainDriver<T> createDrainForDrain(ProcessScript<T> script);  }