// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package demo.sharding;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Clean {
    public static void test(String ds) throws SQLException {
        try(Connection con = DriverManager.getConnection(ConfigJdbc.ds2url(ds), ConfigJdbc.UN, ConfigJdbc.PW)) {
            try(PreparedStatement sel = con.prepareStatement("DELETE FROM t")) {
                int n = sel.executeUpdate();
                System.out.printf("Deleted rows in %s: %d\n", ds, n);
            }
        }
    }
    public static void main(String[] args) throws SQLException {
        test("ds1");
        test("ds2");
    }
}
