public void connect() {
		if (connection != null) {
			throw new IllegalStateException("Already connected!");
		}

		try {
			Class.forName("com.mysql.jdbc.Driver");
			connection = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database
					+ "?useUnicode=true&characterEncoding=utf-8", user, password);

			Statement stmt = connection.createStatement();
			stmt.execute("CREATE TABLE IF NOT EXISTS PartTable (id INT PRIMARY KEY AUTO_INCREMENT, modName TEXT, partName TEXT, INDEX (partName(16)))");

			insertPartStatement = connection.prepareStatement("INSERT INTO PartTable (modName, partName) VALUES (?, ?)");

			// Read database, create index.
			ResultSet result = stmt.executeQuery("SELECT modName, partName FROM PartTable");

			while (result.next()) {
				inMemory.put(result.getString(2), result.getString(1));
			}

			result.close();
		} catch (SQLException | ClassNotFoundException e) {
			LOG.log(Level.FATAL, "Could not connect to database!", e);
			throw new RuntimeException(e);
		}
	}