throws EngineException {
File dbFolder = dbFile.getParentFile();
File mysqlFolder = new File(dbFolder, "mysql");
PortLock portLock = PortUtils.getNextAvailablePort(EmbeddedMySQLConfig.DEFAULT_PORT);
try {
EmbeddedMySQLConfig mysqlConfig = new EmbeddedMySQLConfig(portLock.getPort(),
EmbeddedMySQLConfig.DEFAULT_USER, EmbeddedMySQLConfig.DEFAULT_PASS, mysqlFolder, null);
mySQL = new EmbeddedMySQL(mysqlConfig);
// Trick: start mysql first on the empty dir, stop it, uncompress data, start it again
// This is because mySQL creates some databases by default which doesn't create if "data" already exists
// So we don't need to add them to the produced zip (1.6 MB less).
mySQL.start(true);
mySQL.stop();
CompressorUtil.uncompress(dbFile, mysqlFolder);
mySQL.start(false);
initializeMySQL(mysqlConfig);
} catch(IOException e) {
throw new EngineException(e);
} catch(InterruptedException e) {
throw new EngineException(e);
} catch(SQLException e) {
throw new EngineException(e);
} catch(ClassNotFoundException e) {
throw new EngineException(e);
} finally {
portLock.release();
}
}