@Test public void truncate() throws Exception { h2.execute("INSERT INTO PAIR (KEY, VALUE) VALUES (1, 'Hello, world!')"); try (Connection conn = h2.open()) { JdbcScript<Pair> script = new JdbcScript<>( "testing", new PairSupport(), "PAIR", Arrays.asList("KEY", "VALUE"), null); try (JdbcDrainDriver<Pair> driver = new JdbcDrainDriver<>(profile(), script, conn, true)) { driver.prepare(); driver.put(new Pair(2, "Other")); } test("Other"); } }
private void truncate() throws SQLException { String sql; if (script.getCustomTruncate() == null) { sql = profile.getTruncateStatement(script.getTableName()); } else { sql = script.getCustomTruncate(); } try (Statement truncater = connection.createStatement()) { WGLOG.info("I04001", profile.getResourceName(), script.getName(), script.getTableName()); LOG.debug("Executing SQL: {}", sql); truncater.execute(sql); LOG.debug("Executed SQL: {}", sql); connection.commit(); LOG.debug("Committed {}", sql); } }
JdbcDrainDriver implements DrainDriver<T> { private void truncate() throws SQLException { String sql; if (script.getCustomTruncate() == null) { sql = profile.getTruncateStatement(script.getTableName()); } else { sql = script.getCustomTruncate(); } try (Statement truncater = connection.createStatement()) { WGLOG.info("I04001", profile.getResourceName(), script.getName(), script.getTableName()); LOG.debug("Executing SQL: {}", sql); truncater.execute(sql); LOG.debug("Executed SQL: {}", sql); connection.commit(); LOG.debug("Committed {}", sql); } } }
JdbcDrainDriver implements DrainDriver<T> { private void truncate() throws SQLException { String sql; if (script.getCustomTruncate() == null) { sql = profile.getTruncateStatement(script.getTableName()); } else { sql = script.getCustomTruncate(); } try (Statement truncater = connection.createStatement()) { WGLOG.info("I04001", profile.getResourceName(), script.getName(), script.getTableName()); LOG.debug("Executing SQL: {}", sql); truncater.execute(sql); LOG.debug("Executed SQL: {}", sql); connection.commit(); LOG.debug("Committed {}", sql); } } JdbcDrainDriver(
            JdbcProfile profile,
            JdbcScript<T> script,
            Connection connection,
            boolean truncateOnPrepare); }
JdbcDrainDriver implements DrainDriver<T> { private void truncate() throws SQLException { String sql; if (script.getCustomTruncate() == null) { sql = profile.getTruncateStatement(script.getTableName()); } else { sql = script.getCustomTruncate(); } try (Statement truncater = connection.createStatement()) { WGLOG.info("I04001", profile.getResourceName(), script.getName(), script.getTableName()); LOG.debug("Executing SQL: {}", sql); truncater.execute(sql); LOG.debug("Executed SQL: {}", sql); connection.commit(); LOG.debug("Committed {}", sql); } } JdbcDrainDriver(
            JdbcProfile profile,
            JdbcScript<T> script,
            Connection connection,
            boolean truncateOnPrepare); @Override void prepare(); @Override void put(T object); @Override void close(); }
JdbcDrainDriver implements DrainDriver<T> { private void truncate() throws SQLException { String sql; if (script.getCustomTruncate() == null) { sql = profile.getTruncateStatement(script.getTableName()); } else { sql = script.getCustomTruncate(); } try (Statement truncater = connection.createStatement()) { WGLOG.info("I04001", profile.getResourceName(), script.getName(), script.getTableName()); LOG.debug("Executing SQL: {}", sql); truncater.execute(sql); LOG.debug("Executed SQL: {}", sql); connection.commit(); LOG.debug("Committed {}", sql); } } JdbcDrainDriver(
            JdbcProfile profile,
            JdbcScript<T> script,
            Connection connection,
            boolean truncateOnPrepare); @Override void prepare(); @Override void put(T object); @Override void close();  }