package com.tyndalehouse.step.dataloader; import java.io.IOException; import java.sql.SQLException; import java.util.Calendar; import org.apache.commons.dbutils.DbUtils; import org.apache.log4j.Logger; import org.crosswire.jsword.book.install.InstallException; import org.crosswire.jsword.passage.NoSuchKeyException; import com.tyndalehouse.step.dataloader.common.DateParsingException; import com.tyndalehouse.step.dataloader.loaders.JSwordModuleInstaller; import com.tyndalehouse.step.dataloader.loaders.SchemaLoader; import com.tyndalehouse.step.dataloader.loaders.TimelineLoader; public class Dataloader { private static Logger log = Logger.getLogger(Dataloader.class); private static void cleanup() { ClientDbProvider.tearDown(); } public static void main(String args[]) throws SQLException, ClassNotFoundException, IOException, DateParsingException, NoSuchKeyException, InstallException { try { if(System.getProperty("driver") != null) { DbUtils.loadDriver(System.getProperty("org.apache.derby.jdbc.ClientDriver")); } else { DbUtils.loadDriver("org.apache.derby.jdbc.EmbeddedDriver"); } SchemaLoader sl = new SchemaLoader(); TimelineLoader tl = new TimelineLoader(); JSwordModuleInstaller jmi = new JSwordModuleInstaller(); jmi.installDefaultModules(); long startTime= Calendar.getInstance().getTimeInMillis(); sl.recreateAll(); long currentTime = Calendar.getInstance().getTimeInMillis(); System.out.println("Took " + (currentTime-startTime ) + "ms to create schema"); startTime = currentTime; tl.loadData(); currentTime = Calendar.getInstance().getTimeInMillis(); System.out.println("Took " + (currentTime-startTime ) + "ms to load data"); cleanup(); } catch(Exception ex) { log.error(ex); } } }