public class APIExample {
// JDBC connection pool size
private static final int POOL_SIZE = 10;
// The subsetter
private static Subsetter subsetter =
new Subsetter(
new BasicDataSource(
"org.h2.Driver", "jdbc:h2:" + new File("demo-scott").getAbsolutePath(), "sa", "",
POOL_SIZE,
new File("lib/h2-2.1.212.jar")),
null,
APIExample.class.getResource("Demo-Scott"),
APIExample.class.getResource("Demo-Scott.jm"),
ScriptFormat.SQL);
// The importer
private static Importer importer =
new Importer(
new BasicDataSource(
"org.h2.Driver", "jdbc:h2:" + new File("demo-scott-subset").getAbsolutePath(), "sa", "",
10,
new File("lib/h2-2.1.212.jar")));
/**
* Exports data related with employee "SCOTT"
* and imports it into another database.
*/
public static void main(String[] args) throws SQLException, IOException {
File exportScriptFile = Configuration.getInstance().createTempFile();
subsetter.setUpsertOnly(true); // overwrite previous data
subsetter.execute("NAME='SCOTT'", exportScriptFile);
importer.execute(exportScriptFile);
exportScriptFile.delete();
}
}