Application Programming Interface

The API provides programmatic access to the data export and import functionality.


Dependencies
  • jailer-engine-version.jar (MVN-Repository , also included in jailer-version.zip)
  • log4J

Classes
Example

The example is included in the jailer-engine-version.jar. It extracts some data from the "demo-scott" database and imports it into another database "demo-scott-subset".
  • Packages


    The data model "Demo-Scott" and the extraction model "Demo-Scott.jm" are both embedded into the package and thus accessible as class resources.


  • Source
    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();
    	}
    
    }