public void initConnection()
	{
		// We need to be able to detect if the program has been run for the first time or not
		boolean firstRun = false;

		try
		{
			// Ensure that the SQLite driver is accessible
			Class.forName("org.sqlite.JDBC");
		}
		catch(ClassNotFoundException e)
		{
			Errors.fatalError("Could not load database driver", e);
		}

		try
		{
			// Create a connection to an SQLite database. If ".revisions.db" does
			// not exist, create it in working directory
			connection = DriverManager.getConnection("jdbc:sqlite:" + Main.backupDirectory
					+ "/.revisions.db");
		}
		catch(SQLException e)
		{
			Errors.fatalError("Could not create database connection", e);
		}

		try
		{
			Statement statement = connection.createStatement();

			// Create a metadata request to check if the tables exist. This returns a result
			// set of tables. However, our pattern is very specific, so there should be either
			// zero (table does not exist) or one (table does exist) entries in the result set
			DatabaseMetaData metadata = connection.getMetaData();
			ResultSet revisionsTableExists = metadata.getTables(null, null, "revisions", null);
			ResultSet settingsTableExists = metadata.getTables(null, null, "settings", null);

			// If the revisions table is missing, create it
			if(revisionsTableExists.next())
			{
				logger.info("Existing revisions table found");
			}
			else
			{	
				statement.executeUpdate("CREATE TABLE revisions (id INTEGER PRIMARY KEY ASC,"
						+ " path STRING, diff STRING, binary BLOB, delta INTEGER, filesize INTEGER, time INTEGER)");
				firstRun = true;

				logger.info("Existing revisions table not found; new table created");
			}

			// Likewise for the settings table
			if(settingsTableExists.next())
			{
				logger.info("Existing settings table found");
				
			}
			else
			{
				statement.executeUpdate("CREATE TABLE settings (name STRING, setting STRING)");
				firstRun = true;

				logger.info("Existing settings table not found; new table created");
			}

			// If it is the first run, that's up to the Control to do
			if(firstRun)
			{
				return;	
			}
			// If this isn't the first run, fetch the live directory. 
			// Get the rows of the settings table and loop through them, searching for the
			// live directory path
			ResultSet settingsRows = statement.executeQuery("SELECT * FROM settings WHERE name = 'liveDirectory'");
			while(settingsRows.next())
			{
				if(settingsRows.getString("name").equals("liveDirectory"))
				{
					Main.liveDirectory = Paths.get(settingsRows.getString("setting"));
				}
			}
		}
		catch(SQLException e)
		{
			Errors.fatalError("Database table creation failed", e);
		}

		logger.debug("Database connection successfully initialized");
	}