<commit_before>package com.laytonsmith.database;

import com.laytonsmith.core.Profiles;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.SQLException;
import java.util.Map;

/**
 *
 */
@Profiles.ProfileType(type = "mysql")
public class MySQLProfile extends SQLProfile {

	private final String host;
	private final int port;
	private final String database;
	private final String username;
	private final String password;
	private final Boolean useSSL;

	public MySQLProfile(String id, Map<String, String> elements) throws Profiles.InvalidProfileException {
		super(id, elements);
		if(!elements.containsKey("database")) {
			throw new Profiles.InvalidProfileException("Required \"database\" tag is missing for profile \"" + id + "\"");
		}
		database = elements.get("database");
		if(elements.containsKey("username")) {
			username = elements.get("username");
		} else {
			username = null;
		}
		if(elements.containsKey("password")) {
			password = elements.get("password");
		} else {
			password = <PASSWORD>;
		}
		if(elements.containsKey("host")) {
			host = elements.get("host");
		} else {
			host = "localhost";
		}
		if(elements.containsKey("port")) {
			try {
				port = Integer.parseInt(elements.get("port"));
			} catch (NumberFormatException ex) {
				throw new Profiles.InvalidProfileException(ex.getMessage());
			}
		} else {
			port = 3306;
		}
		if(elements.containsKey("useSSL")) {
			useSSL = Boolean.parseBoolean(elements.get("useSSL"));
		} else {
			useSSL = null;
		}
	}

	public String getDatabase() {
		return database;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	@Override
	public String getConnectionString() throws SQLException {
		try {
			Class.forName(com.mysql.cj.jdbc.Driver.class.getName());
		} catch (ClassNotFoundException ex) {
			throw new SQLException("Cannot load MySQL. Check your installation and try again");
		}
		try {
			return "jdbc:mysql://" + host + ":" + port + "/" + database + "?generateSimpleParameterMetadata=true"
					+ "&jdbcCompliantTruncation=false"
					+ (username == null ? "" : "&user=" + URLEncoder.encode(username, "UTF-8"))
					+ (password == null ? "" : "&password=" + URLEncoder.encode(password, "UTF-8"))
					+ (useSSL == null ? "" : "&useSSL=" + useSSL);
		} catch (UnsupportedEncodingException ex) {
			throw new Error();
		}
	}

	@Override
	public String toString() {
		return super.toString() + " " + host + ":" + port + " username=" + username;
	}

}<commit_msg>Add autoReconnect=true to mysql profile<commit_after>package com.laytonsmith.database;

import com.laytonsmith.core.Profiles;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.SQLException;
import java.util.Map;

/**
 *
 */
@Profiles.ProfileType(type = "mysql")
public class MySQLProfile extends SQLProfile {

	private final String host;
	private final int port;
	private final String database;
	private final String username;
	private final String password;
	private final Boolean useSSL;

	public MySQLProfile(String id, Map<String, String> elements) throws Profiles.InvalidProfileException {
		super(id, elements);
		if(!elements.containsKey("database")) {
			throw new Profiles.InvalidProfileException("Required \"database\" tag is missing for profile \"" + id + "\"");
		}
		database = elements.get("database");
		if(elements.containsKey("username")) {
			username = elements.get("username");
		} else {
			username = null;
		}
		if(elements.containsKey("password")) {
			password = elements.get("password");
		} else {
			password = <PASSWORD>;
		}
		if(elements.containsKey("host")) {
			host = elements.get("host");
		} else {
			host = "localhost";
		}
		if(elements.containsKey("port")) {
			try {
				port = Integer.parseInt(elements.get("port"));
			} catch (NumberFormatException ex) {
				throw new Profiles.InvalidProfileException(ex.getMessage());
			}
		} else {
			port = 3306;
		}
		if(elements.containsKey("useSSL")) {
			useSSL = Boolean.parseBoolean(elements.get("useSSL"));
		} else {
			useSSL = null;
		}
	}

	public String getDatabase() {
		return database;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	@Override
	public String getConnectionString() throws SQLException {
		try {
			Class.forName(com.mysql.cj.jdbc.Driver.class.getName());
		} catch (ClassNotFoundException ex) {
			throw new SQLException("Cannot load MySQL. Check your installation and try again");
		}
		try {
			return "jdbc:mysql://" + host + ":" + port + "/" + database
					+ "?generateSimpleParameterMetadata=true"
					+ "&jdbcCompliantTruncation=false"
					+ "&autoReconnect=true"
					+ (username == null ? "" : "&user=" + URLEncoder.encode(username, "UTF-8"))
					+ (password == null ? "" : "&password=" + URLEncoder.encode(password, "UTF-8"))
					+ (useSSL == null ? "" : "&useSSL=" + useSSL);
		} catch (UnsupportedEncodingException ex) {
			throw new Error();
		}
	}

	@Override
	public String toString() {
		return super.toString() + " " + host + ":" + port + " username=" + username;
	}

}
{'fraction_non_alphanumeric': 0.14623739332816135, 'fraction_numerical': 0.0023273855702094647, 'mean_word_length': 4.031219512195122, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2492898', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1578, 'n_words': 361}